Forums

PHP

This topic is locked

Pure PHP Upload - updating/deleting records

Posted 08 Aug 2003 15:03:43
1
has voted
08 Aug 2003 15:03:43 Andrew Clausen posted:
Hello,

I purchased the Pure PHP Upload Bundle a while ago and it has helped me save a lot of time. I am running into a problem, however. From the Add-On Pack, I cannot get the Delete File before record or the Delete File before Update features to work. I can't find any tutorials covering this process either.

I am uploading the images to a dynamic folder and need to insert an interface to update/replace existing images. I can't find any information on this, so I hope somebody here can help me. It would load the update page, display current images and preferablye have a button (file field) below each of 10 images to update them. It needs to a) delete the old image from the dynamic folder and b) insert the new image path in the database (fields imgpath1, imgpath2, etc. to imgpath10).

Thanks a ton for any help on this!

Replies

Replied 08 Aug 2003 15:25:11
08 Aug 2003 15:25:11 Martha Graham replied:
There are tutorials under the help button of the UI of the Pure PHP Upload Add-on Pack.
Hope they help you.

Martha Graham
DMXzone manager
Replied 08 Aug 2003 15:58:58
08 Aug 2003 15:58:58 Andrew Clausen replied:
I followed tuhe supplied tutorial and couldn't get it to work...

ANyways, I can do without the Deleting before updating/deleting - my main concern is this:

For the file fields to update the existing images, is there a way to automatically insert the current image path in the file fields? Right now, they are blank and they overwrite the existing image paths.

Thanks for any help!
Replied 11 Aug 2003 11:19:39
11 Aug 2003 11:19:39 Patrick Woldberg replied:
You have to change the Update SQL

$updateSQL = sprintf("UPDATE images SET imgpath1=COALESCE(%s,imgpath1), imgpath2=COALESCE(%s,imgpath2), imgpath3=COALESCE(%s,imgpath3) ... etc.

If you have an older version of MySQL you could use IFNULL instead of COALESCE. The function COALESCE fills is a check if a value is null, if no file is selected in the filefield the update record will leave this fields the old value.

--------------------------------------------------
Patrick Woldberg
Web Developer at Dynamic Zones
Manager at DMXzone.com
--------------------------------------------------
Replied 13 Aug 2003 15:43:17
13 Aug 2003 15:43:17 Andrew Clausen replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
You have to change the Update SQL

$updateSQL = sprintf("UPDATE images SET imgpath1=COALESCE(%s,imgpath1), imgpath2=COALESCE(%s,imgpath2), imgpath3=COALESCE(%s,imgpath3) ... etc.

If you have an older version of MySQL you could use IFNULL instead of COALESCE. The function COALESCE fills is a check if a value is null, if no file is selected in the filefield the update record will leave this fields the old value.

--------------------------------------------------
Patrick Woldberg
Web Developer at Dynamic Zones
Manager at DMXzone.com
--------------------------------------------------
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Worked perfectly! Thanks for the help!

Reply to this topic