Jump to content

Broken Image Upload


dachshund

Recommended Posts

I recently changed hosts, now my image uploader which used to work fine doesn't work.

 


		$indeximage = $_FILES['indeximage'];

		if($indeximage) {

		$indeximagename = basename($_FILES['indeximage']['name']);
      		$indeximagenew = $_SERVER['DOCUMENT_ROOT'] . '/images/uploaded/index/' . $indeximagename;

      			if (!file_exists($indeximagenew)) {

				if ((move_uploaded_file($_FILES['indeximage']['tmp_name'], $indeximagenew)) === true) {
				echo 'Index Image uploaded to this address ';
				echo 'http://www.address.co.uk/images/uploaded/index/';
				echo $indeximagename;
				echo '<br />';
				}else	{
					echo 'Unable to move Index Image into the right folder.';
				}
			}
		}

 

It now echos Unable to move Index Image into the right folder.

 

I tried putting:

 


ini_set("display_errors", "1");
error_reporting(E_ALL);

 

at the beginning. Before the upload it reads:

 

Notice: Undefined index: images in /var/www/vhosts/huhmagazine.co.uk/httpdocs/admin/images.php on line 58 Notice: Undefined index: indeximage in /var/www/vhosts/huhmagazine.co.uk/httpdocs/admin/images.php on line 62

 

After it reads:

 

Warning: move_uploaded_file(): Unable to move '/tmp/phpTd67fh' to '/var/www/vhosts/huhmagazine.co.uk/httpdocs/images/uploaded/index/calidewitt.jpg' in /var/www/vhosts/huhmagazine.co.uk/httpdocs/admin/images.php on line 71

Link to comment
Share on other sites

The notice's are essentially telling you that you're upload form isn't working as you are expecting it to. The index you are requesting from the array does not exist. So either the file input field in your form isn't called indeximage or you don't have the multipart on the form tag.

 

The warning will be a result from the notices, no doubt. Also ensure you have correct permissions.

 

First step I would take is to print_r($_FILES); to see if anything is being posted correctly. Could be something to do with file size limits as well. Hard to tell. You just need to debug it at the moment.

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.