You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by John Iliffe <jo...@iliffe.ca> on 2010/01/16 19:35:37 UTC

Re: [users@httpd] Very Very strange problem in opensuse 11.1, file uploading reports "not an image file"

There are a couple of choices to debug here.

First, the code you supplied is comparing the mime-type parameters
obtained from the call to:

 $upload_file_type = $GLOBALS
['HTTP_POST_FILES']['profile_image']['type'];

So, first I would echo $upload_file_type and see what it is actually
getting.  

Second, in_array() is case sensitive - see if the mime-type is somehow
getting upper case; the $file_type_list function may be converting to
upper. 

Third, what is the client doing to set the mime-type?  This is probably
OK (why  mentioned it last) but maybe the type of the upload files is
not being set correctly/at all?

Also, I checked and $GLOBALS simply lists ALL variables in global scope.
So, somewhere you should have a function extracting 'HTTP_POST_FILES'
from the POST data.  (global variable $HTTP_RAW_POST_DATA).  You might
want to check that.  Try printing out the $GLOBALS array and see if
there is a variable in it called HTTP_POST_FILES using print_r().  This
will print the array member name => array member value which should
help.

You will have to do more but at least knowing where the problem is is a
good start!
=====================================================
On Sat, 2010-16-01 at 22:42 +0530, J. Bakshi wrote:
> On Sat, 16 Jan 2010 17:31:28 +0100
> Marcin 'Rambo' Roguski <ra...@id.uw.edu.pl> wrote:
> 
> > On Sat, 16 Jan 2010 21:48:15 +0530
> > "J. Bakshi" <jo...@infoservices.in> wrote:
> > 
> > > Dear list,
> > 
> > > that it simply reports "Not an Image file". And this is happening
> > > with all files even with image ( jpg, bmp etc..) and with as small
> > > as 1KB and as big as 500KB. I have checked the log with "Loglevel
> > > debug" and there is nothing in the error log which can give any
> > > hints.
> > 
> > Can you check if the files are actually uploaded and are viewable with
> > ordinary image viewer? This looks like problem with PHP or CGI script
> > you use to upload than apache. Enable error reporting in php.ini if
> > it's not on. Analyze the script that serves as upload gateway.
> 
> Many thanks for your kind attention. I have already checked in the suse server and the files are not uploaded in the folder where they suppose to be. Though in debian server the folders do have all the uploaded files. Regarding the script, I have found codes which are actually doing the upload (though I am not a php coder)
> 
> ` ` `
> 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','image>
>       $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;
>            else
>             $msg = 'Over size file';
>        }
>        else
>           $msg = 'Not an Image file';
> 
> ` ` `
> 
> Error reporting is already enabled in vhost configuration
> 
>   	php_flag display_startup_errors on
>         php_flag display_errors on
>         php_flag html_errors on
> 
> Kindly suggest me what else to do.
> 
> Thanks
> 
> 
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
> 


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Very Very strange problem in opensuse 11.1, file uploading reports "not an image file"

Posted by John Iliffe <jo...@iliffe.ca>.
On Sun, 2010-17-01 at 11:30 +0530, J. Bakshi wrote:
> On Sat, 16 Jan 2010 13:35:37 -0500
> John Iliffe <jo...@iliffe.ca> wrote:
> 
> > There are a couple of choices to debug here.
> > 
> > First, the code you supplied is comparing the mime-type parameters
> > obtained from the call to:
> > 
> >  $upload_file_type = $GLOBALS
> > ['HTTP_POST_FILES']['profile_image']['type'];
> > 
> > So, first I would echo $upload_file_type and see what it is actually
> > getting.  
> > 
> > Second, in_array() is case sensitive - see if the mime-type is somehow
> > getting upper case; the $file_type_list function may be converting to
> > upper. 
> > 
> > Third, what is the client doing to set the mime-type?  This is
> > probably OK (why  mentioned it last) but maybe the type of the upload
> > files is not being set correctly/at all?
> > 
> > Also, I checked and $GLOBALS simply lists ALL variables in global
> > scope. So, somewhere you should have a function extracting
> > 'HTTP_POST_FILES' from the POST data.  (global variable
> > $HTTP_RAW_POST_DATA).  You might want to check that.  Try printing
> > out the $GLOBALS array and see if there is a variable in it called
> > HTTP_POST_FILES using print_r().  This will print the array member
> > name => array member value which should help.
> > 
> > You will have to do more but at least knowing where the problem is is
> > a good start!
> 
> 
> Hello,
> 
> Thanks for your kind response and clarification. Regarding debug I have
> a good idea rather than flipping through the code written by some one
> else because I am not a php coder and hope you will also  like it.
> I have only and only one option. Check with a php code that file can be
> uploaded with the same filetype check used in the previous code and if
> it fails then find out why so. Can I get a simple image uploader php
> code with the file type checking and some good echo to see what is
> actually happening in the net ? And if the code can do its job
> successfully then it might be not a server side problem. Can you
> suggest me any link which provides such a code ? In the mean time I am
> also looking for it through google but getting a direction from the
> experienced one is always great.
> 
> ---------------------------------------------------------------------
No, sorry I can't help you there unfortunately.  I'm not a very
experienced PHP coder either; I just used it to create a basic web
server.  I don't do uploads so no samples available.

I noticed certain items in your code the linked it to the mime-type and
figured that if you can echo what is actually happening so you can see
it, then you can fix it.  

You might be able to get some help at:

 http://ca3.php.net/manual/en/index.php

the PHP online manual. It has a lot of sample code contributed by users.




> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
> 


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Very Very strange problem in opensuse 11.1, file uploading reports "not an image file"

Posted by "J. Bakshi" <jo...@infoservices.in>.
On Sat, 16 Jan 2010 13:35:37 -0500
John Iliffe <jo...@iliffe.ca> wrote:

> There are a couple of choices to debug here.
> 
> First, the code you supplied is comparing the mime-type parameters
> obtained from the call to:
> 
>  $upload_file_type = $GLOBALS
> ['HTTP_POST_FILES']['profile_image']['type'];
> 
> So, first I would echo $upload_file_type and see what it is actually
> getting.  
> 
> Second, in_array() is case sensitive - see if the mime-type is somehow
> getting upper case; the $file_type_list function may be converting to
> upper. 
> 
> Third, what is the client doing to set the mime-type?  This is
> probably OK (why  mentioned it last) but maybe the type of the upload
> files is not being set correctly/at all?
> 
> Also, I checked and $GLOBALS simply lists ALL variables in global
> scope. So, somewhere you should have a function extracting
> 'HTTP_POST_FILES' from the POST data.  (global variable
> $HTTP_RAW_POST_DATA).  You might want to check that.  Try printing
> out the $GLOBALS array and see if there is a variable in it called
> HTTP_POST_FILES using print_r().  This will print the array member
> name => array member value which should help.
> 
> You will have to do more but at least knowing where the problem is is
> a good start!


Hello,

Thanks for your kind response and clarification. Regarding debug I have
a good idea rather than flipping through the code written by some one
else because I am not a php coder and hope you will also  like it.
I have only and only one option. Check with a php code that file can be
uploaded with the same filetype check used in the previous code and if
it fails then find out why so. Can I get a simple image uploader php
code with the file type checking and some good echo to see what is
actually happening in the net ? And if the code can do its job
successfully then it might be not a server side problem. Can you
suggest me any link which provides such a code ? In the mean time I am
also looking for it through google but getting a direction from the
experienced one is always great.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org