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
https://forums.phpfreaks.com/topic/219178-broken-image-upload/
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
https://forums.phpfreaks.com/topic/219178-broken-image-upload/#findComment-1136561
Share on other sites

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.