Jump to content

Need help with image upload problem..


phpnoobie9

Recommended Posts

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

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?

 

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.