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

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.