httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "J. Bakshi" <>
Subject Re: [users@httpd] Very Very strange problem in opensuse 11.1, file uploading reports "not an image file"
Date Mon, 18 Jan 2010 14:43:58 GMT
On Sat, 16 Jan 2010 19:37:36 +0100
Marcin 'Rambo' Roguski <> wrote:


> What about temporary files? Are they uploaded or not?
> From what you're writing, neither size or type are
> identified (should be set after a successful completion
> of POST request).
> Can you add
> print_r($GLOBALS['HTTP_POST_FILES']['profile_image'])
> in the function?

Dear all,

I know it is offtopic to discuss php in apache list, but I might be
permitted to share my findings with you all which is very interesting.

I know nothing about php but I tried to upload file in the same server
with a different code collected from net. And this time the upload is
working !!! Not only in debian server but in the suse server too :-)

Still the question is why the previous code works on debian and not on
suse. both the codes are given at button

debian serevr
Apache/2.2.9 (Debian)
PHP 5.2.6-1+lenny4 with Suhosin-Patch 

suse server
PHP 5.2.6 with Suhosin-Patch 

new php code for uploading ( collected from net ) ( running on both debian & suse  server

` ` `
   // Configuration - Your Options
      $allowed_filetypes = array('.jpg','.gif','.bmp','.png'); // These
will be the types of file that will pass the validation.
      $max_filesize = 524288; // Maximum filesize in BYTES (currently
0.5MB). $upload_path = './upload/'; // The place the files will be
uploaded to (currently a 'files' di rectory).

   $filename = $_FILES['userfile']['name']; // Get the name of the file
(including file extension). $ext = substr($filename,
strpos($filename,'.'), strlen($filename)-1); // Get the extension from
t he filename.

   // Check if the filetype is allowed, if not DIE and inform the user.
      die('The file you attempted to upload is not allowed.');

   // Now check the filesize, if it is too large then DIE and inform
the user. if(filesize($_FILES['userfile']['tmp_name']) > $max_filesize)
      die('The file you attempted to upload is too large.');

   // Check if we can upload to the specified path, if not DIE and
inform the user. if(!is_writable($upload_path))
      die('You cannot upload to the specified directory, please CHMOD
it to 777.');

   // Upload the file to your specified path.
   if(move_uploaded_file($_FILES['userfile']['tmp_name'],$upload_path .
$filename)) echo 'Your file upload was successful, view the file <a
href="' . $upload_path . $filename . '" title="Your File">here</a>'; //
It worked. else
         echo 'There was an error during the file upload.  Please try
again.'; // It failed :(.

` ` `

and here is the old one ( running on debian lenny server only )

` ` `
function fileUploder(){
      $upload_file_path = 'fileadmin/user_upload/images/profile/';
      $file_size = 1000000;
      $file_type_list= Array('image/png','image/jpeg','image/gif','application/octet-stream')
      $upload_flag = false;
      $msg = '';
      $target_path = '';

      // Check the file parameters
       $upload_file_type = $GLOBALS['HTTP_POST_FILES']['profile_image']['type'];
       if(in_array($upload_file_type, $file_type_list))
          // file type is ok
          if($GLOBALS['HTTP_POST_FILES']['profile_image']['size'] < $file_size)
            $upload_flag = true;
            $msg = 'Over size file';
          $msg = 'Not an Image file';

` ` `


The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message