Re: Upload File Type Problem
Thanks for the syntax.
"Shawn Wilson" <shawn@glassgia nt.com> wrote in message
news:40488B7B.1 D913D37@glassgi ant.com...[color=blue]
> Xenophobe wrote:
>[color=green][color=darkred]
> > > > > I developed a simple tool to allow users to upload .GIF image[/color][/color][/color]
files.[color=blue][color=green][color=darkred]
> > > > >
> > > > > It works great on my dev box and $_FILES['file']['type'] returns
> > > > > "image/gif", but on the prod site it returns[/color]
> > "applicatio n/octet-stream".[color=darkred]
> > > >
> > > > It looks as though your browser was unable to determine the Content-
> > > > Type, so it correctly fell back to application/octet-stream. How
> > > > would you like to deal with that?
> > > >
> > > > Beware that browsers are not obliged to provide Content-Type
> > > > information; nor are they required to provide the original filename
> > > > in any form, so you cannot rely on checking the extension, if
> > > > present, either.[/color]
> >
> > Is it possible to determine the file type using getimagesize() without
> > saving the file to disk first? I didn't see anything on php.net, but[/color][/color]
thought[color=blue][color=green]
> > it didn't hurt to ask.[/color]
>
> You can use getimagesize on the file while it's still in the tmp[/color]
directory,[color=blue]
> before you move it to a permanent location. You can't use it while it's[/color]
still[color=blue]
> on the user's system.
>
> getimagesize($_ FILES['filename']['tmp_name']);
>
> Regards,
> Shawn
>
> --
> Shawn Wilson
> shawn@glassgian t.com
> http://www.glassgiant.com[/color]
Upload File Type Problem
Collapse
This topic is closed.
X
X
-
Guest replied -
Guest repliedRe: Upload File Type Problem
You can't access client side file info w/o using ActiveX and an applet.
I've actually used a nifty third party applet, JUpload. It was development
for use with ASP, but works great with PHP as well.
Anyway, thanks for the info re: getimagesize(). I will implement this right
away.
"John Dunlop" <john+usenet@jo hndunlop.info> wrote in message
news:MPG.1ab240 b79bfe4dea9896c 6@News.Individu al.NET...[color=blue]
> Xenophobe wrote upsidedown:
>[color=green]
> > "Chung Leong" <chernyshevsky@ hotmail.com> wrote in message
> > news:CMmdnRKNJO cdXNrdRVn-jQ@comcast.com. ..
> >[color=darkred]
> > > Uzytkownik "John Dunlop" <john+usenet@jo hndunlop.info> napisal w
> > > wiadomosci news:MPG.1ab175 7b979554729896c 3@News.Individu al.NET...
> > >
> > > > It looks as though your browser was unable to determine the Content-
> > > > Type, so it correctly fell back to application/octet-stream. How
> > > > would you like to deal with that?
> > >
> > > Yup. It's better use getimagesize() to check the actual image time.[/color][/color]
>
> Yes! I'd forgotten about that. Thanks.
>[color=green]
> > Is it possible to determine the file type using getimagesize() without
> > saving the file to disk first?[/color]
>
> Yes, getimagesize has URL support. See
>
> http://www.php.net/manual/en/function.getimagesize.php
>
> It's not possible to determine the image type when it's on the user's
> system though.
>
> --
> Jock[/color]
Leave a comment:
-
Guest repliedRe: Upload File Type Problem
Xenophobe wrote:
[color=blue][color=green][color=darkred]
> > > > I developed a simple tool to allow users to upload .GIF image files.
> > > >
> > > > It works great on my dev box and $_FILES['file']['type'] returns
> > > > "image/gif", but on the prod site it returns[/color][/color]
> "applicatio n/octet-stream".[color=green][color=darkred]
> > >
> > > It looks as though your browser was unable to determine the Content-
> > > Type, so it correctly fell back to application/octet-stream. How
> > > would you like to deal with that?
> > >
> > > Beware that browsers are not obliged to provide Content-Type
> > > information; nor are they required to provide the original filename
> > > in any form, so you cannot rely on checking the extension, if
> > > present, either.[/color][/color]
>
> Is it possible to determine the file type using getimagesize() without
> saving the file to disk first? I didn't see anything on php.net, but thought
> it didn't hurt to ask.[/color]
You can use getimagesize on the file while it's still in the tmp directory,
before you move it to a permanent location. You can't use it while it's still
on the user's system.
getimagesize($_ FILES['filename']['tmp_name']);
Regards,
Shawn
--
Shawn Wilson
shawn@glassgian t.com
Leave a comment:
-
Guest repliedRe: Upload File Type Problem
Xenophobe wrote upsidedown:
[color=blue]
> "Chung Leong" <chernyshevsky@ hotmail.com> wrote in message
> news:CMmdnRKNJO cdXNrdRVn-jQ@comcast.com. ..
>[color=green]
> > Uzytkownik "John Dunlop" <john+usenet@jo hndunlop.info> napisal w
> > wiadomosci news:MPG.1ab175 7b979554729896c 3@News.Individu al.NET...
> >[color=darkred]
> > > It looks as though your browser was unable to determine the Content-
> > > Type, so it correctly fell back to application/octet-stream. How
> > > would you like to deal with that?[/color]
> >
> > Yup. It's better use getimagesize() to check the actual image time.[/color][/color]
Yes! I'd forgotten about that. Thanks.
[color=blue]
> Is it possible to determine the file type using getimagesize() without
> saving the file to disk first?[/color]
Yes, getimagesize has URL support. See
It's not possible to determine the image type when it's on the user's
system though.
--
Jock
Leave a comment:
-
Guest repliedRe: Upload File Type Problem
Is it possible to determine the file type using getimagesize() without
saving the file to disk first? I didn't see anything on php.net, but thought
it didn't hurt to ask.
"Chung Leong" <chernyshevsky@ hotmail.com> wrote in message
news:CMmdnRKNJO cdXNrdRVn-jQ@comcast.com. ..[color=blue]
> Yup. It's better use getimagesize() to check the actual image time.
>
> Uzytkownik "John Dunlop" <john+usenet@jo hndunlop.info> napisal w[/color]
wiadomosci[color=blue]
> news:MPG.1ab175 7b979554729896c 3@News.Individu al.NET...[color=green]
> > Xenophobe wrote:
> >[color=darkred]
> > > I developed a simple tool to allow users to upload .GIF image files.
> > >
> > > It works great on my dev box and $_FILES['file']['type'] returns
> > > "image/gif", but on the prod site it returns[/color][/color][/color]
"applicatio n/octet-stream".[color=blue][color=green]
> >
> > It looks as though your browser was unable to determine the Content-
> > Type, so it correctly fell back to application/octet-stream. How
> > would you like to deal with that?
> >
> > Beware that browsers are not obliged to provide Content-Type
> > information; nor are they required to provide the original filename
> > in any form, so you cannot rely on checking the extension, if
> > present, either.
> >
> > --
> > Jock[/color]
>
>[/color]
Leave a comment:
-
Guest repliedRe: Upload File Type Problem
Hey Jock,
I've look at several alternate ways to determine the file type. I'm somewhat
limited because the web hosting service is running 4.2.3 and most of the
easier ways require 4.3.
I think getimagesize is probably my best option.
Security isn't a huge issue because the admin pages are in a
password-protected directory and will only be used by the client's trusted
staff.
Thanks.
"John Dunlop" <john+usenet@jo hndunlop.info> wrote in message
news:MPG.1ab175 7b979554729896c 3@News.Individu al.NET...[color=blue]
> Xenophobe wrote:
>[color=green]
> > I developed a simple tool to allow users to upload .GIF image files.
> >
> > It works great on my dev box and $_FILES['file']['type'] returns
> > "image/gif", but on the prod site it returns "applicatio n/octet-stream".[/color]
>
> It looks as though your browser was unable to determine the Content-
> Type, so it correctly fell back to application/octet-stream. How
> would you like to deal with that?
>
> Beware that browsers are not obliged to provide Content-Type
> information; nor are they required to provide the original filename
> in any form, so you cannot rely on checking the extension, if
> present, either.
>
> --
> Jock[/color]
Leave a comment:
-
Guest repliedRe: Upload File Type Problem
Yup. It's better use getimagesize() to check the actual image time.
Uzytkownik "John Dunlop" <john+usenet@jo hndunlop.info> napisal w wiadomosci
news:MPG.1ab175 7b979554729896c 3@News.Individu al.NET...[color=blue]
> Xenophobe wrote:
>[color=green]
> > I developed a simple tool to allow users to upload .GIF image files.
> >
> > It works great on my dev box and $_FILES['file']['type'] returns
> > "image/gif", but on the prod site it returns "applicatio n/octet-stream".[/color]
>
> It looks as though your browser was unable to determine the Content-
> Type, so it correctly fell back to application/octet-stream. How
> would you like to deal with that?
>
> Beware that browsers are not obliged to provide Content-Type
> information; nor are they required to provide the original filename
> in any form, so you cannot rely on checking the extension, if
> present, either.
>
> --
> Jock[/color]
Leave a comment:
-
Guest repliedRe: Upload File Type Problem
Xenophobe wrote:
[color=blue]
> I developed a simple tool to allow users to upload .GIF image files.
>
> It works great on my dev box and $_FILES['file']['type'] returns
> "image/gif", but on the prod site it returns "applicatio n/octet-stream".[/color]
It looks as though your browser was unable to determine the Content-
Type, so it correctly fell back to application/octet-stream. How
would you like to deal with that?
Beware that browsers are not obliged to provide Content-Type
information; nor are they required to provide the original filename
in any form, so you cannot rely on checking the extension, if
present, either.
--
Jock
Leave a comment:
-
Upload File Type Problem
I developed a simple tool to allow users to upload .GIF image files.
It works great on my dev box and $_FILES['file']['type'] returns
"image/gif", but on the prod site it returns "applicatio n/octet-stream".
Any suggestions would be greatly appreciated.
Tags: None
Leave a comment: