close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Deleting file and filename

Thread began 2/13/2010 10:48 am by paul386190 | Last modified 2/17/2010 11:31 am by paul386190 | 908 views | 7 replies |

paul386190

Deleting file and filename

Hi there

I have a profile update page within which clients can update details about themselves - one of the elements is a photo. I have the page updating fine if they update the photo or any of the text. However, I've now placed a 'delete photo' button beside the existing photo and assigned a 'delete file' action to it. This does indeed remove the file from the server, but I'm unable to remove the filename from the appropriate database field.

Is there a way I can do this other than displaying an additional text field to show the current file name and requiring them to hit the 'delete photo' button, then remove the text displaying in that text field and then hitting the 'Update' button?

Many thanks in advance.
Paul

Sign in to reply to this post

anonymous

Paul,

The way to do this would be to now use DataAssist's update single record behavior found in the server behaviors tab.

After you select update single record - set the trigger to when the delete photo button is pressed.

Pick the table you want to update and then after hitting next on the first wizard menu, you will see the bindings for each column value... simply set your column which holds the photo name to nothing or NULL depending on how your database is setup.

Best regards,

Brian

Sign in to reply to this post

paul386190

Hi Brian, many thanks for the response.

Unfortunately I've just tried that and it hasn't made any change.

I've selected 'Update single record', chosen the correct trigger button (Button: deletephoto pressed), selected the right connection (ltm) and table (ltm_drivers) , selected the id of the table as the key column (driver_id) and set the value as 'driver_id' from the existing Recordset I named 'drivers'. Then on pressing 'Next' left all the columns empty as advised (these will be ignored) apart from the relevant column 'driver_photo' which I have set the value as NULL. If I left it empty I understand that it is ignored.

Once the page is uploaded over the previous version and tested, pressing the button 'deletephoto' removes the image file from the server, but still doesn't remove the filename from the database.

Do you have any ideas as to where I could be going wrong? Would it make any difference if I applied the 'Update single record' behavior first to the button and then applied the 'delete file' behavior? I'm guessing that may not work though as once it's removed the name from the database table there won't be a file name to reference when it goes to delete the file.

Many thanks in advance.
Paul

Sign in to reply to this post

anonymous

Paul,

You will want the delete file behavior to run first... what about setting the trigger to "delete file successful". That should be an option. I think the other you need to do now that I think about is make sure you have enclosed the delete photo button within a form. You will also want to put a hidden field within the form where you have the value of the row's id. That way when you are updating the row, you can specify the correct id.

Let me know what you find out... after that, if there are still problems; if you can, post the code here and I will take a look at it.

Brian

Sign in to reply to this post

paul386190

Hi Brian, many thanks. Unfortunately neither of those have resolved the situation.

I'm guessing there is probably something obvious I've missed, however I'm more of a designer than a coder. I've attached the page code as requested and would be grateful for any assistance.

Kind regards
Paul

Attached Files
drivercode.zip
Sign in to reply to this post

Dani Chankhour

I think an easier way of doing this, would be to remove the update server behavior when clicking the delete button, and instead you could just add this code:

<?php
if(isset($_POST["deletephoto"])){
$_POST['currentphoto'] = "";
}
?>

before your regular update server behavior. And set the trigger to be any form post for the update server behavior.

Sign in to reply to this post

paul386190

Hi Dani
Many thanks for the response, unfortunately I still can't get it to work.
I've placed that code just before...

<?php
// WA Application Builder Update
if (isset($_POST["updatedriver"])) // Trigger
{...

But when I then try to use the page and hit UPDATE it refreshes the page, doesn't remove the filename and displays a warning message at the top which reads...

Cannot modify header information - headers already sent by (output started at /../../../../admin/updateadriver.php:105) in /../../../../admin/updateadriver.php on line 150

In my file here, line 105 is the opening <?php of the code you suggested while line 150 is header("Location: ".$WA_redirectURL);

If it's any help, the trigger I am using for the regular update server behavior is a button named 'updatedriver'.

I would be very grateful for any further assistance you can offer.
Kind regards

Paul

Sign in to reply to this post

paul386190

Hi Dani

Just to let you know that I've now managed to resolve the issue. I've simply applied a single record update to the delete button and set the target to 'deletephoto pressed' rather than 'delete file successful' as had been earlier suggested, and this now works perfectly.

Thank you again for your assistance.
Kind regards

Paul

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...