Note that there are some explanatory texts on larger screens.

plurals
  1. POmove_uploaded_file doesn't work, no error
    text
    copied!<p>I am running running a script which moves an uploaded file with <code>move_uploaded_file()</code>. I have done this thousands of times but for some reason it's not working. I have confimred the following:</p> <ol> <li><code>&lt;form&gt;</code> using <code>method="post"</code> and correct <code>enctype</code></li> <li>correct file referenced from form</li> <li>directory has permissions <code>777</code></li> <li>all the <code>memory_limit</code>, <code>max_execution_time</code>, etc are set to super high settings to avoid timeouts</li> </ol> <p>Basically, the script below returns with just <code>Your image is too big.</code>. I have also enabled ALL errors to display and still don't get an error. Any ideas?</p> <pre><code>$time = time(); $target_path = "/absolute/path/to/temp/directory/temp/"; $target_path = $target_path.$time.'.jpg'; if(move_uploaded_file($_FILES['image']['tmp_name'], $target_path)) { } else{ $error .= '&lt;li&gt;Your image is too big.&lt;/li&gt;'; } </code></pre> <p>Using 1and1 hosting with the php.ini hack :P</p> <p><strong>UPDATE 1</strong></p> <p>I would like to add that response from the script occurs exactly after 60 seconds.</p> <p><strong>UPDATE 2</strong></p> <p>We might be getting somewhere with this. Just <code>print_r($_FILES)</code> and this is the result of the array:</p> <pre><code>Array ( [image] =&gt; Array ( [name] =&gt; P2120267.JPG [type] =&gt; [tmp_name] =&gt; [error] =&gt; 1 [size] =&gt; 0 ) ) </code></pre> <p>So that leads me to believe that the file isn't be uploaded correctly to the server or something? I have checked and the post form is <code>&lt;form action="" method="post" enctype="multipart/form-data"&gt;</code>. So, from what I can tell, the file isn't being uploaded to the server's temp area?</p> <p><strong>UPDATE 3</strong></p> <p>Noticed the <code>[error] =&gt; 1</code> in the above array. This is apparently down to <a href="http://php.net/manual/en/features.file-upload.errors.php">the filesize being larger than the <code>upload_max_filesize</code></a>. However, when i set this as <code>128M</code>, I get a white screen of death after 60 seconds. The file I'm uploading is 2.5MB</p> <p>Here is my php.ini file:</p> <pre><code>register_globals=off memory_limit = 128M max_execution_time=3600 post_max_size = 128M upload_max_filesize= 128M </code></pre> <p><strong>UPDATE 4</strong></p> <p>With details above, it appears that I am getting a WSOD, but the image is being upoaded. So, how to stop the WSOD? I can't find any errors related anywhere.</p> <p><strong>UPDATE 5 - FOUND IT!</strong></p> <p>Shame on me for not giving you guys all the code. It looks like its to do with this line:</p> <pre><code>resizeImage($feedBurnerStatsSource, PHOTOMSGDIR.'temp/'.$time.'-tmp.jpg',$width,$height); </code></pre> <p>In the following code:</p> <pre><code>function resizeImage($source, $destination = NULL,$wdt, $height = NULL){ if(empty($height)){ // Height is nit set so we are keeping the same aspect ratio. list($width, $height) = getimagesize($source); if($width &gt; $height){ $w = $wdt; $h = ($height / $width) * $w; $w = $w; }else{ $w = $wdt; $h = $w; $w = ($width / $height) * $w; } }else{ // Both width and Height are set. // this will reshape to the new sizes. $w = $wdt; $h = $height; } $source_image = @file_get_contents($source) or die('Could not open'.$source); $source_image = @imagecreatefromstring($source_image) or die($source.' is not a valid image'); $sw = imagesx($source_image); $sh = imagesy($source_image); $ar = $sw/$sh; $tar = $w/$h; if($ar &gt;= $tar){ $x1 = round(($sw - ($sw * ($tar/$ar)))/2); $x2 = round($sw * ($tar/$ar)); $y1 = 0; $y2 = $sh; }else{ $x1 = 0; $y1 = 0; $x2 = $sw; $y2 = round($sw/$tar); } $slate = @imagecreatetruecolor($w, $h) or die('Invalid thumbnail dimmensions'); imagecopyresampled($slate, $source_image, 0, 0, $x1, $y1, $w, $h, $x2, $y2); // If $destination is not set this will output the raw image to the browser and not save the file if(!$destination) header('Content-type: image/jpeg'); @imagejpeg($slate, $destination, 75) or die('Directory permission problem'); ImageDestroy($slate); ImageDestroy($source_image); if(!$destination) exit; return true; } </code></pre> <p>So, WSOD means that its some sort of die without a message. Any ideas?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload