Jump to content

simple-image.php error


fife

Recommended Posts

ok so ive found what looks to be a decent image uploader. which if anyone is interested can be found here;

 

http://www.white-hat-web-design.co.uk/blog/resizing-images-with-php/

 

I have followed the instruction and added the few bits needed to make it work properly.  However hence me beening here, it doesnt work.  Im not overly familiar with the syntax of -> so maybe I am outputting the wrong name in the move_upload_file but the error I get on the server is

 

 

Unable to move '/tmp/phpJnOkXP' to bla bla bla upload-new.php on line 126

Upload fail

 

 

which is the move_upload line Here is my code

 

  <?php
	if( isset($_POST['uploadbtn']) ) {
$folder = "{$_SERVER['DOCUMENT_ROOT']}/images/test/";
$fileName = $_FILES['newImage']['name'];
$tmpName = $_FILES['image']['tmp_name'];

      include('../simple-image.php');
      $image = new SimpleImage();
      $image->load($tmpName);
      $image->resizeToWidth(600);
      $image->output();

   
   
  $uploaded =  move_uploaded_file($tmpName , $folder.$fileName);
    
   if($uploaded){
echo "Upload success";   
   }
   else {
   echo "Upload fail";
   } }

	?>
     <form action="" method="post" enctype="multipart/form-data" name="uploadfrm">
     	<input name="image" type="file" />
        <input name="uploadbtn" value="Upload" type="submit" />
     </form>

Link to comment
https://forums.phpfreaks.com/topic/259498-simple-imagephp-error/
Share on other sites

<?php
	if( isset($_POST['uploadbtn']) ) {
$folder = "{$_SERVER['DOCUMENT_ROOT']}/images/test/";
$fileName = $_FILES['newImage']['name'];
$tmpName = $_FILES['image']['tmp_name'];

      include('../simple-image.php');
      $image = new SimpleImage();
      $image->load($tmpName);
      $image->resizeToWidth(600);
      $image->save($folder.$fileName);
      $image->output(); //don't output unless you change your headers to an image/type

if(file_exists($folder.$fileName)) {
echo 'Upload was successful!';
} else {
echo 'Upload failed!';
}
?>
     <form action="" method="post" enctype="multipart/form-data" name="uploadfrm">
     	<input name="image" type="file" />
        <input name="uploadbtn" value="Upload" type="submit" />
     </form>

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.