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
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?

 

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.