This is a discussion on upload script question within the alt.comp.lang.php forums, part of the PHP Programming Forums category; All, I'm currently working on a photo upload script using PHP. Everything appears to work fine for the most ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
All,
I'm currently working on a photo upload script using PHP. Everything appears to work fine for the most part, however it appears that some of my images do not show up with any type... so, I'm running my script using: if ($_FILES['imagefile']['type'] == "image/jpeg" || $_FILES['imagefile']['type'] == "image/pjpeg") However, some photos have a type of nothing... so, though the file is .jpg, the upload will fail as it's not getting the type of jpeg out of the $_FILES array. I've tried opening the actual images that aren't working and saving them as .jpg to make sure something didn't go bad on the original save, but have the same problem. Anyone seen this or know of a fix? |
|
|||
|
Man, I'm stuck here - Any ideas from anyone?
"Jon" <jonra@netins.com> wrote in message news:dmqete$55s$1@news.netins.net... > All, > > I'm currently working on a photo upload script using PHP. Everything > appears to work fine for the most part, however it appears that some of my > images do not show up with any type... so, I'm running my script using: > > if ($_FILES['imagefile']['type'] == "image/jpeg" || > $_FILES['imagefile']['type'] == "image/pjpeg") > > However, some photos have a type of nothing... so, though the file is > .jpg, the upload will fail as it's not getting the type of jpeg out of the > $_FILES array. I've tried opening the actual images that aren't working > and saving them as .jpg to make sure something didn't go bad on the > original save, but have the same problem. > > Anyone seen this or know of a fix? > |
|
|||
|
I've never posted for help on a newsgroup before an exhaustive search on
google and my other normal resources. This solution unfortunately brings me to the same problem - Is it possible these images are just bad? If so, is there a way to "repair" them, or work with them anyways? "Steve" <googlespam@nastysoft.com> wrote in message news:1133803179.878192.163940@g49g2000cwa.googlegr oups.com... > >> Man, I'm stuck here - Any ideas from anyone? > > Google, as always, is Your Friend. > > <http://groups.google.co.uk/group/comp.lang.php/browse_thread/thread/7ef0ec08401c5718/99f781b04378d2da#99f781b04378d2da> > > --- > Steve > |
|
|||
|
"Jon" wrote:
> All, > > I'm currently working on a photo upload script using PHP. Everything appears > to work fine for the most part, however it appears that some of my images do > not show up with any type... so, I'm running my script using: > > if ($_FILES['imagefile']['type'] == "image/jpeg" || > $_FILES['imagefile']['type'] == "image/pjpeg") > > However, some photos have a type of nothing The mime type in $_FILES[]['type'] contains data provided by the client, so it isn't necessarily reliable, any it may not exist at all. Instead, try using mime_content_type() to check the actual uploaded file. http://uk.php.net/mime_content_type -- phil [dot] ronan @ virgin [dot] net http://vzone.virgin.net/phil.ronan/ |
|
|||
|
www.0com.net
I can part with my script for $50 "Jon" <jonra@netins.com> wrote in message news:dn23s5$b5v$1@news.netins.net... > I've never posted for help on a newsgroup before an exhaustive search on > google and my other normal resources. > > This solution unfortunately brings me to the same problem - Is it possible > these images are just bad? If so, is there a way to "repair" them, or work > with them anyways? > > "Steve" <googlespam@nastysoft.com> wrote in message > news:1133803179.878192.163940@g49g2000cwa.googlegr oups.com... >> >>> Man, I'm stuck here - Any ideas from anyone? >> >> Google, as always, is Your Friend. >> >> <http://groups.google.co.uk/group/comp.lang.php/browse_thread/thread/7ef0ec08401c5718/99f781b04378d2da#99f781b04378d2da> >> >> --- >> Steve >> > > |
|
|||
|
For whatever reason, I can't use this function with our host. PHP 4.4.1
should be compadable, but it doesn't work. Any other possible ways? Also - to Mr. Anonymous - Your script is only validating by file type, I was able to save a text file as .jpg and upload it without problems. Plus, spamming sucks :\ "Philip Ronan" <invalid@invalid.invalid> wrote in message news:BFBA4671.3C098%invalid@invalid.invalid... > "Jon" wrote: > >> All, >> >> I'm currently working on a photo upload script using PHP. Everything >> appears >> to work fine for the most part, however it appears that some of my images >> do >> not show up with any type... so, I'm running my script using: >> >> if ($_FILES['imagefile']['type'] == "image/jpeg" || >> $_FILES['imagefile']['type'] == "image/pjpeg") >> >> However, some photos have a type of nothing > > The mime type in $_FILES[]['type'] contains data provided by the client, > so > it isn't necessarily reliable, any it may not exist at all. > > Instead, try using mime_content_type() to check the actual uploaded file. > > http://uk.php.net/mime_content_type > > -- > phil [dot] ronan @ virgin [dot] net > http://vzone.virgin.net/phil.ronan/ > |
|
|||
|
Ok, I'm an idiot. The problem with my script not finding the file type was
because I set my MAX_FILE_SIZE too low, and the transfer of the file would fail from one page to the next, therefor there was obviously no file type to get. Live and learn - thanks for the help guys :) "Jon" <jonra@netins.com> wrote in message news:dn75cg$3ta$1@news.netins.net... > For whatever reason, I can't use this function with our host. PHP 4.4.1 > should be compadable, but it doesn't work. Any other possible ways? > > Also - to Mr. Anonymous - Your script is only validating by file type, I > was able to save a text file as .jpg and upload it without problems. Plus, > spamming sucks :\ > > > "Philip Ronan" <invalid@invalid.invalid> wrote in message > news:BFBA4671.3C098%invalid@invalid.invalid... >> "Jon" wrote: >> >>> All, >>> >>> I'm currently working on a photo upload script using PHP. Everything >>> appears >>> to work fine for the most part, however it appears that some of my >>> images do >>> not show up with any type... so, I'm running my script using: >>> >>> if ($_FILES['imagefile']['type'] == "image/jpeg" || >>> $_FILES['imagefile']['type'] == "image/pjpeg") >>> >>> However, some photos have a type of nothing >> >> The mime type in $_FILES[]['type'] contains data provided by the client, >> so >> it isn't necessarily reliable, any it may not exist at all. >> >> Instead, try using mime_content_type() to check the actual uploaded file. >> >> http://uk.php.net/mime_content_type >> >> -- >> phil [dot] ronan @ virgin [dot] net >> http://vzone.virgin.net/phil.ronan/ >> > > |
|
|||
|
someone's already done the footwork by making classes that examine the file
headers to detect the filetype. http://phpthumb.sourceforge.net/ "Jon" <jonra@netins.com> wrote in message news:dmqete$55s$1@news.netins.net... > All, > > I'm currently working on a photo upload script using PHP. Everything > appears to work fine for the most part, however it appears that some of my > images do not show up with any type... so, I'm running my script using: > > if ($_FILES['imagefile']['type'] == "image/jpeg" || > $_FILES['imagefile']['type'] == "image/pjpeg") > > However, some photos have a type of nothing... so, though the file is > .jpg, the upload will fail as it's not getting the type of jpeg out of the > $_FILES array. I've tried opening the actual images that aren't working > and saving them as .jpg to make sure something didn't go bad on the > original save, but have the same problem. > > Anyone seen this or know of a fix? > |
|
|||
|
and from another post I learned about mime_content_type('php.gif')
"Jon" <jonra@netins.com> wrote in message news:dmqete$55s$1@news.netins.net... > All, > > I'm currently working on a photo upload script using PHP. Everything > appears to work fine for the most part, however it appears that some of my > images do not show up with any type... so, I'm running my script using: > > if ($_FILES['imagefile']['type'] == "image/jpeg" || > $_FILES['imagefile']['type'] == "image/pjpeg") > > However, some photos have a type of nothing... so, though the file is > .jpg, the upload will fail as it's not getting the type of jpeg out of the > $_FILES array. I've tried opening the actual images that aren't working > and saving them as .jpg to make sure something didn't go bad on the > original save, but have the same problem. > > Anyone seen this or know of a fix? > |