Re: [PHP] Image upload not working correctly
Thanks for the reponse. Yes, the destination paths look fine and the PHP error log displays no errors. Any other ideas? Thanks. Jason Wong [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Thursday 14 October 2004 02:40, Dave Grant wrote: echo Thumb image uploaded to .$thumbPath.br /\n; echo Full image uploaded to .$fullPath.br /\n; Do these look OK? Everything works fine, except that the images are simply not there when we go look for them. The best explanation I can come up with is that they are not moved, but I have no idea why. I've done this with no problem on my personal site. Is it a problem with the move_uploaded_file function? Any ideas? What does the PHP error log say? -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Faith goes out through the window when beauty comes in at the door. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image upload not working correctly
Just to clarify, everything looks like it works fine except for moving the images to the destination path. The images upload, the server recognizes them, but they don't get moved to the destination path. Thanks. Jason Wong [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Thursday 14 October 2004 02:40, Dave Grant wrote: echo Thumb image uploaded to .$thumbPath.br /\n; echo Full image uploaded to .$fullPath.br /\n; Do these look OK? Everything works fine, except that the images are simply not there when we go look for them. The best explanation I can come up with is that they are not moved, but I have no idea why. I've done this with no problem on my personal site. Is it a problem with the move_uploaded_file function? Any ideas? What does the PHP error log say? -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Faith goes out through the window when beauty comes in at the door. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image upload not working correctly
Please do not top-post. On Thursday 14 October 2004 23:52, Dave Grant wrote: Thanks for the reponse. Yes, the destination paths look fine and the PHP error log displays no errors. Any other ideas? move_uploaded_file() _will_ spit out an error if there are any problems. So if you're _positive_ FULL error reporting is enabled logged and the error log shows nothing then I would be inclined to assume that the move_uploaded_file() operation was executed successfully. In that case, are you positive you're looking in the correct place for the destination file? If you're still having problems, post some self-contained, concise[1] code to illustrate your problem. [1] concise meaning the bare minimum, eg in your case code to handle either thumb image or full image but not both, etc. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* The Heineken Uncertainty Principle: You can never be sure how many beers you had last night. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Image upload not working correctly
Hello. I am working on a rather large form for my work that accepts, among other things, 2 images, one smaller one 65 x 93 pixels, and a larger one 105 x 150 pixels, both in JPG format. Let me run through the whole process, showing my code. I use simple, standard HTML for the form: input type=file name=thumbImage size=15 input type=file name=fullImage size=15 I check the $_FILES array to make sure the server uploads the images: array(2) { [thumbImage]= array(5) { [name]= string(15) DAK01_thumb.jpg [type]= string(11) image/pjpeg [tmp_name]= string(14) /tmp/phpXxmX1s [error]= int(0) [size]= int(7161) } [fullImage]= array(5) { [name]= string(14) DAK01_full.jpg [type]= string(11) image/pjpeg [tmp_name]= string(14) /tmp/php05LOkc [error]= int(0) [size]= int(12235) } } I do the following error checking for various things: // Small Thumbnail Image if (trim($_FILES[thumbImage][tmp_name])) { if ($_FILES[thumbImage][size] 10240) { $formVars[results] .= The small photo must be 10240 bytes or lessbr /; } if ($_FILES[thumbImage][type] != image/pjpeg $_FILES[thumbImage][type] != image/jpeg) { $formVars[results] .= The small photo must be in .jpg formatbr /; } $imgSize = getimagesize($_FILES[thumbImage][tmp_name]); if ($imgSize[0] 65) { $formVars[results] .= The small photo must be 65 pixels wide or lessbr /; } } // Full Image if (trim($_FILES[fullImage][tmp_name])) { if ($_FILES[fullImage][size] 20480) { $formVars[results] .= The large photo must be 20480 bytes or lessbr /; } if ($_FILES[fullImage][type] != image/pjpeg $_FILES[fullImage][type] != image/jpeg) { $formVars[results] .= The large photo must be in .jpg formatbr /; } $imgSize = getimagesize($_FILES[fullImage][tmp_name]); if ($imgSize[0] 105) { $formVars[results] .= The large photo must be 105 pixels wide or lessbr /; } } Then, I move the temp image files: // Copy image to $GLOBALS[dvdimgpath].$_POST[gameId]._[thumb/full].jpg $thumbPath = $GLOBALS[dvdimgpath].$_POST[gameId]._thumb.jpg; $fullPath = $GLOBALS[dvdimgpath].$_POST[gameId]._full.jpg; echo Thumb image uploaded to .$thumbPath.br /\n; if (!move_uploaded_file($_FILES[thumbImage][tmp_name], $thumbPath)) { $formVars[results] .= Image file could not moved to the images dir. Please try again; } echo Full image uploaded to .$fullPath.br /\n; if (!move_uploaded_file($_FILES[fullImage][tmp_name], $fullPath)) { $formVars[results] .= Image file could not moved to the images dir. Please try again; } Everything works fine, except that the images are simply not there when we go look for them. The best explanation I can come up with is that they are not moved, but I have no idea why. I've done this with no problem on my personal site. Is it a problem with the move_uploaded_file function? Any ideas? Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image upload not working correctly
On Thursday 14 October 2004 02:40, Dave Grant wrote: echo Thumb image uploaded to .$thumbPath.br /\n; echo Full image uploaded to .$fullPath.br /\n; Do these look OK? Everything works fine, except that the images are simply not there when we go look for them. The best explanation I can come up with is that they are not moved, but I have no idea why. I've done this with no problem on my personal site. Is it a problem with the move_uploaded_file function? Any ideas? What does the PHP error log say? -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Faith goes out through the window when beauty comes in at the door. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php