Pure PHP Upload 2 Support Product Page
Answered
Issue with renamed files not being written to the database correctly on update
Asked 24 Apr 2010 01:56:21
1
has this question
24 Apr 2010 01:56:21 Dave Buchholz posted:
I have used PHP Pure Upload, Smart Image Processor, Upload Add-on Pack in the admin system that I am building but I have an issue where on the update page if the image being uploaded has the same name as an existing image the image uploaded is renamed as image_1.jpg but the value written to the database is the original name of the image i.e. image.jpgmy PPU code looks like so:
// Pure PHP Upload 2.1.10 $ppu = new pureFileUpload(); $ppu->path = "../../uploads/".$i8_upload; $ppu->extensions = "GIF,JPG,JPEG,PNG"; $ppu->formName = "frmUpdate"; $ppu->storeType = "file"; $ppu->sizeLimit = ""; $ppu->nameConflict = "uniq"; $ppu->requireUpload = "false"; $ppu->minWidth = ""; $ppu->minHeight = ""; $ppu->maxWidth = ""; $ppu->maxHeight = ""; $ppu->saveWidth = ""; $ppu->saveHeight = ""; $ppu->timeout = "600"; $ppu->progressBar = ""; $ppu->progressWidth = "300"; $ppu->progressHeight = "100"; $ppu->redirectURL = ""; $ppu->checkVersion("2.1.10"); $ppu->doUpload();
my SIP code looks like so:
<?php // Smart Image Processor PHP 2.0.7 if (isset($_GET['GP_upload'])) { $sipp2 = new cGraphicMediator("upload", $ppu, ""); $sipp2->setComponent("Auto"); $sipp2->setMatteColor("#FFFFFF"); $sipp2->resize(230, 230, true); $sipp2->sharpen(); $sipp2->overwrite = false; $sipp2->setMask("##path####name##_thumb.jpg"); $sipp2->saveJPEG(100); $sipp2->process(); } ?> <?php // Smart Image Processor PHP 2.0.7 if (isset($_GET['GP_upload'])) { $sipp1 = new cGraphicMediator("upload", $ppu, ""); $sipp1->setComponent("Auto"); $sipp1->setMatteColor("#FFFFFF"); $sipp1->resize(120, 120, true); $sipp1->sharpen(); $sipp1->overwrite = false; $sipp1->setMask("##path####name##_tiny.jpg"); $sipp1->saveJPEG(100); $sipp1->process(); } ?> and my database update code (using WebAssist's DataAssist( looks like so: $WA_fieldNamesStr = "title|details|image|image2|personalisation1|personalisation2|personalisation3|personalisation4|personalisation5|sortorder|featured|publish|tstampinsert|url|dateinsert|admininsert"; $WA_fieldValuesStr = "".((isset($_POST["title"]))?$_POST["title"]:"") ."" . "|" . "".((isset($_POST["details"]))?$_POST["details"]:"") ."" . "|" . "".((!empty($_POST["image"]))?$_FILES["image"]["fileName"]:$_POST["originalImage"]) ."" . "|" . "".((!empty($_POST["image2"]))?$_FILES["image2"]["fileName"]:$_POST["originalImage2"]) ."" . "|" . "".((isset($_POST["personalisation1"]))?$_POST["personalisation1"]:"") ."" . "|" . "".((isset($_POST["personalisation2"]))?$_POST["personalisation2"]:"") ."" . "|" . "".((isset($_POST["personalisation3"]))?$_POST["personalisation3"]:"") ."" . "|" . "".((isset($_POST["personalisation4"]))?$_POST["personalisation4"]:"") ."" . "|" . "".((isset($_POST["personalisation5"]))?$_POST["personalisation5"]:"") ."" . "|" . "".((isset($_POST["sortorder"]))?$_POST["sortorder"]:"") ."" . "|" . "".((isset($_POST["featured"]))?$_POST["featured"]:"") ."" . "|" . "".((isset($_POST["publish"]))?$_POST["publish"]:"") ."" . "|" . "".time() ."" . "|" . "".((isset($_POST["title"]))?i8_UrlParameter($_POST["title"]):"") ."" . "|" . "".date('Y-m-d', time()) ."" . "|" . "".$_SESSION['adminID'] ."";
I am working with CS4 on Snow Leopard.
How can I resolve this please ?
Promoted Answers
Replied 27 Apr 2010 17:11:28
I have come up with a solution that meets "MY" needs which might not suit everybody, but by using $ppu->uploadedFiles['image']->fileName and $ppu->uploadedFiles['image2']->fileName I can retrieve the correct image name like so:
Hope that helps people in the future who have the same issue.
$WA_fieldValuesStr = "".((isset($_POST["title"]))?$_POST["title"]:"") ."" . "|" . "".((isset($_POST["details"]))?$_POST["details"]:"") ."" . "|" . "".((!empty($_POST["image"]))?$ppu->uploadedFiles['image']->fileName:$_POST["originalImage"]) ."" . "|" . "".((!empty($_POST["image2"]))?$ppu->uploadedFiles['image2']->fileName:$_POST["originalImage2"]) ."" . "|" . "".((isset($_POST["sortorder"]))?$_POST["sortorder"]:"") ."" . "|" . "".((isset($_POST["publish"]))?$_POST["publish"]:"") ."" . "|" . "".time() ."" . "|" . "".((isset($_POST["title"]))?i8_UrlParameter($_POST["title"]):"") ."" . "|" . "".date('Y-m-d', time()) ."" . "|" . "".$_SESSION['adminID'] ."";
Hope that helps people in the future who have the same issue.
Replied 27 Apr 2010 15:32:10
Hello Dave,
Sorry for the delay,
When you use the Overwrite Conflict Handling and there is an image with the same name existing it will be overwritten by the new one. I can advise you to use the rename function on SIP to create a new filename for each uploaded file and a simple logic to make that name unique by using a part or the hole session id.
Regards,
Sorry for the delay,
When you use the Overwrite Conflict Handling and there is an image with the same name existing it will be overwritten by the new one. I can advise you to use the rename function on SIP to create a new filename for each uploaded file and a simple logic to make that name unique by using a part or the hole session id.
Regards,
Replies
Replied 26 Apr 2010 09:51:35
26 Apr 2010 09:51:35 Miroslav Zografski replied:
Hello Dave,
Your issue is because of the conflict handling set up in Pure PHP Upload -> unique. Set it to Overwrite. This way he new file will replace the existing one.
Regards,
Your issue is because of the conflict handling set up in Pure PHP Upload -> unique. Set it to Overwrite. This way he new file will replace the existing one.
Regards,
Replied 26 Apr 2010 09:59:09
26 Apr 2010 09:59:09 Dave Buchholz replied:
What will happen if another item has the same image associated with it, will the new image being uploaded be renamed ?
If not this will solve my issue entirely because I need to make sure that if there are any conflicts the new image is renamed and that name is written to the database.
Thanks
If not this will solve my issue entirely because I need to make sure that if there are any conflicts the new image is renamed and that name is written to the database.
Thanks
Replied 27 Apr 2010 15:14:27
27 Apr 2010 15:14:27 Dave Buchholz replied:
Can I get a definitive answer on this please ?
Replied 27 Apr 2010 15:32:10
27 Apr 2010 15:32:10 Miroslav Zografski replied:
Hello Dave,
Sorry for the delay,
When you use the Overwrite Conflict Handling and there is an image with the same name existing it will be overwritten by the new one. I can advise you to use the rename function on SIP to create a new filename for each uploaded file and a simple logic to make that name unique by using a part or the hole session id.
Regards,
Sorry for the delay,
When you use the Overwrite Conflict Handling and there is an image with the same name existing it will be overwritten by the new one. I can advise you to use the rename function on SIP to create a new filename for each uploaded file and a simple logic to make that name unique by using a part or the hole session id.
Regards,
Replied 27 Apr 2010 15:37:46
27 Apr 2010 15:37:46 Dave Buchholz replied:
If I use the rename function in SIP will this name be written to the database ?
Replied 27 Apr 2010 15:53:42
27 Apr 2010 15:53:42 Miroslav Zografski replied:
Hello Dave,
Yes, it must be.
Regards,
Yes, it must be.
Regards,
Replied 27 Apr 2010 17:11:28
27 Apr 2010 17:11:28 Dave Buchholz replied:
I have come up with a solution that meets "MY" needs which might not suit everybody, but by using $ppu->uploadedFiles['image']->fileName and $ppu->uploadedFiles['image2']->fileName I can retrieve the correct image name like so:
Hope that helps people in the future who have the same issue.
$WA_fieldValuesStr = "".((isset($_POST["title"]))?$_POST["title"]:"") ."" . "|" . "".((isset($_POST["details"]))?$_POST["details"]:"") ."" . "|" . "".((!empty($_POST["image"]))?$ppu->uploadedFiles['image']->fileName:$_POST["originalImage"]) ."" . "|" . "".((!empty($_POST["image2"]))?$ppu->uploadedFiles['image2']->fileName:$_POST["originalImage2"]) ."" . "|" . "".((isset($_POST["sortorder"]))?$_POST["sortorder"]:"") ."" . "|" . "".((isset($_POST["publish"]))?$_POST["publish"]:"") ."" . "|" . "".time() ."" . "|" . "".((isset($_POST["title"]))?i8_UrlParameter($_POST["title"]):"") ."" . "|" . "".date('Y-m-d', time()) ."" . "|" . "".$_SESSION['adminID'] ."";
Hope that helps people in the future who have the same issue.