upload script question

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 ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-02-2005
Jon
 
Posts: n/a
Default upload script question

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?


Reply With Quote
  #2 (permalink)  
Old 12-05-2005
Jon
 
Posts: n/a
Default Re: upload script question

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?
>



Reply With Quote
  #3 (permalink)  
Old 12-05-2005
Steve
 
Posts: n/a
Default Re: upload script question


> 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

Reply With Quote
  #4 (permalink)  
Old 12-05-2005
Jon
 
Posts: n/a
Default Re: upload script question

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
>



Reply With Quote
  #5 (permalink)  
Old 12-05-2005
Philip Ronan
 
Posts: n/a
Default Re: upload script question

"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/

Reply With Quote
  #6 (permalink)  
Old 12-07-2005
Mr. Anonymous
 
Posts: n/a
Default Re: upload script question

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
>>

>
>



Reply With Quote
  #7 (permalink)  
Old 12-07-2005
Jon
 
Posts: n/a
Default Re: upload script question

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/
>



Reply With Quote
  #8 (permalink)  
Old 12-07-2005
Jon
 
Posts: n/a
Default Re: upload script question

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/
>>

>
>



Reply With Quote
  #9 (permalink)  
Old 01-16-2006
Jim Michaels
 
Posts: n/a
Default Re: upload script question

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?
>



Reply With Quote
  #10 (permalink)  
Old 01-16-2006
Jim Michaels
 
Posts: n/a
Default Re: upload script question

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?
>



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 11:27 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0