close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Trying to delete file from database and server.

Thread began 8/27/2016 3:43 pm by EmmaMorris | Last modified 8/31/2016 9:44 am by Ray Borduin | 1831 views | 10 replies |

EmmaMorris

Trying to delete file from database and server.

You guys have been a great help with every problem I have had and have either given me a fix or a workaround...

I hate to keep bothering but here is a good one.

I have an edit record form, which works perfectly except for the delete file function, There are areas to upload 1 picture and 15 documents on the form.
I have added a check box next to each document field to mark for deletion.
The only one on the field I want you to look at is document 3. 3 is the only one I have changed at this point. UploadResult4 points to document3 since the photo is the first upload.

Attached is the file.
I got the code I used from this post here: http://www.webassist.com/forums/posts.php?id=20042
Just cannot get it to work. I am so close to having this working the way I need it to..
Thanks.

Sign in to reply to this post

Ray BorduinWebAssist

The issue is with the update server behavior. You have that field set to "Ignore" if blank, which doesn't allow you to actually update it to a blank value.

On line 364 you have:
$UpdateQuery->bindColumn("document3", "s", "".$WA_DFP_UploadStatus["WA_UploadResult4"]["serverFileName"] ."", "WA_IGNORE");

I think it would work if you had:
$UpdateQuery->bindColumn("document3", "s", "".$WA_DFP_UploadStatus["WA_UploadResult4"]["serverFileName"] ."", "WA_BLANK");

Sign in to reply to this post
Did this help? Tips are appreciated...

EmmaMorris

All I can say is, you rock.. That was it.. well part of it.. Its not deleting it off of the server. Just the database.

I appreciate you guys a ton. I have learned a lot just from my problems that you have helped with.

UPDATE
I updated all the lines so they were WA_Blank and also modified all the other documents so they were all like the document3 line except with the correct document numbers.. Problem is, if I check one for delete and then hit the submit button it deletes ALL of the documents in the database (not from the server). Plus then when change any one of the documents, it updates that document and deletes all the others...


The uploaded file has those lines changed back to IGNORE instead of BLANK. Now I can upload files again. Very confused at this point.

Sign in to reply to this post

Ray BorduinWebAssist

You will have to start by giving the checkbox fields values so you can verify if they have been checked or not. So instead of:
<input name="doc1del" type="checkbox" value="" />

It should be:
<input name="doc1del" type="checkbox" value="1" />

Then you have to set the default image value to the field in the database when they aren't deleting. So for instance on line 52 instead of:
'DefaultFileName' => "".((($_POST["doc1del"] != "delete"))?$_POST["document1"]:"") ."",
you would have:
'DefaultFileName' => "".((isset($_POST["doc1del"]) && $_POST["doc1del"] == "1")?"":$Recordset1->getColumnVal("document1")) ."",

That way if they checked delete it sets the value to blank, otherwise it leaves the existing value from the recordset.

Sign in to reply to this post
Did this help? Tips are appreciated...

EmmaMorris

Ok.. We are closer.. 2 problems.
I uploaded 7 documents 1-7.. They show fine in the database. If I choose 1 to delete. say #3 , it deletes all the rest and leaves 3 (but id does delete them off the server as well). Like its is backwards.

The other issue is, if there are files in there, say one on Document 4, and I upload a new ones to Document 1 2 & 3 , they upload fine but delete 4.
I looked and looked but I just dont see it.
Thanks for your help.

Sign in to reply to this post

Ray BorduinWebAssist

Please attach a current version of the page for me to look at.

Sign in to reply to this post
Did this help? Tips are appreciated...

EmmaMorris

Sorry Meant to do that.

Sign in to reply to this post

Ray BorduinWebAssist

Try this syntax for the default file name:

'DefaultFileName' => "".((isset($_POST["doc1del"]) && $_POST["doc1del"] == "1")?"":$Recordset1->getColumnVal("document1")) ."",

I forgot that checkboxes that are unchecked won't exist in the post.

Sign in to reply to this post
Did this help? Tips are appreciated...

EmmaMorris

I hate to keep bothering you..
That did it for the database part but not deleting the file from the server.. SOOOO close..!
Current attached.

Sign in to reply to this post

Ray BorduinWebAssist

You don't even have the delete file server behaviors applied on the page. You will need to start with that. Apply one for each file. Trigger based on the checkbox and delete the file referenced from the database.

Sign in to reply to this post
Did this help? Tips are appreciated...
loading

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...