Okay, I started seeing some of my mistakes.

I am still having a great deal of trouble:


newfile returns: 0fdae2e9e6aa43f067a9dd780a5a36a6.jpg
image_file returns: images/jpg/test/0fdae2e9e6aa43f067a9dd780a5a36a6.jpg

images/jpg/test is set to 777 but I still get (Could not move file to destination). What am I missing? Thanks!


<?php

error_reporting(E_ALL);

      $uploaddir = "images/jpg/test/";


      print_r($_FILES);

      $local_file = $_FILES['userfile']['tmp_name'];



if (sizeof($local_file))
  {

//try to get image size; this returns false if this is not an actual image file.
      $image_test = getimagesize($local_file);

        if ($image_test !== false) {
           $mime_type = $_FILES['userfile']['type'];
           switch($mime_type) {
               case "image/jpeg":
                   $pext = 'jpg';
                   break;
               case "image/tiff":
                   $pext = 'tif';
                   break;
               default:
echo "The file you are trying to upload is an image, but it is not a tif or jpeg and therefore unacceptable.";
           }
} else {
   echo "The file you are trying to upload is not a valid image file";
}

 $newfile = md5(date("l-F-j-Y i:s")).'.'.$pext;

 $image_file = $uploaddir . $newfile;

// print_r($newfile);
// print_r($image_file);
        
 if(!move_uploaded_file($newfile,$image_file)) {
        
         echo 'Could not move file to destination';
         exit;
 }

 else {
         echo 'image file <?php echo $newfile ?> uploaded.';



 }



  }

  ?>

<form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
    <input type="hidden" name="MAX_FILE_SIZE" value="300000" />
    <!-- Name of input element determines name in $_FILES array -->
    Cartoon: <input name="userfile" type="file" />
    <input type="submit" value="Upload File" />
</form>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to