phpnoobie9 Posted March 6, 2008 Share Posted March 6, 2008 I used WAMP5 to test my files and everything was working fine. I then tested live and my file won't upload images. I have the image md5 and have the name sent to the database. I'm receiving the image name in the database, but the actual image is not uploading..it was uploading fine on WAMP5. The permissions on the image folders are set to 777 The actual image upload file is in my administrative folder. Image upload code: //Start image upload //Check for an image $newname = md5(time()*rand(1,99999).$_FILES['image']['name']); $newname2 = $newname.'.jpg'; if (move_uploaded_file ($_FILES['image']['tmp_name'], $_SERVER['DOCUMENT_ROOT'].'images/'.$newname2)) { echo '<p>Image uploaded</p>'; } else { echo '<p>Problem uploading image</p>'; } //End image upload The image upload form section: <form enctype="multipart/form-data" action="upload.php" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="307200" /> <input type="file" name="image" size="50" /> <input type="submit" name="submit" value="SUBMIT" /> </form> Link to comment https://forums.phpfreaks.com/topic/94609-need-help-with-image-upload-problem/ Share on other sites More sharing options...
phpSensei Posted March 6, 2008 Share Posted March 6, 2008 How would you know the file is always Jpg? unless thats the only type allowed. $newname2 = $newname.'.jpg'; Never use "MAX_FILE_SIZE", because this can be edited by the user, causing him to upload a massive file. Link to comment https://forums.phpfreaks.com/topic/94609-need-help-with-image-upload-problem/#findComment-484449 Share on other sites More sharing options...
phpnoobie9 Posted March 6, 2008 Author Share Posted March 6, 2008 This is only for my personal use and I only upload jpg. Link to comment https://forums.phpfreaks.com/topic/94609-need-help-with-image-upload-problem/#findComment-484458 Share on other sites More sharing options...
phpnoobie9 Posted March 6, 2008 Author Share Posted March 6, 2008 I think it's the tmp file for the upload. My phpinfo shows no value for upload_tmp_dir. I went into phpini and unsemi coloned it and added a directory to it.... ; Temporary directory for HTTP uploaded files (will use system default if not ; specified). upload_tmp_dir = /tmp/ Restarted apache and phpinfo still shows no value? Link to comment https://forums.phpfreaks.com/topic/94609-need-help-with-image-upload-problem/#findComment-484491 Share on other sites More sharing options...
PFMaBiSmAd Posted March 6, 2008 Share Posted March 6, 2008 Your code has no error checking to get it to tell you why the upload failed. Rather than guess as to what the problem is, start by adding the following to see what you are getting, if anything - echo "<pre>"; print_r($_FILES); echo "</pre>"; There will be an ['error'] element (assuming the server accepts the upload request) and it will have one of the following values - http://www.php.net/manual/en/features.file-upload.errors.php Also, you need to make sure that the php.ini that you are changing is the one that php is using. Are uploads even enabled in the php.ini? Link to comment https://forums.phpfreaks.com/topic/94609-need-help-with-image-upload-problem/#findComment-484557 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.