Current location: Hot Scripts Forums » Programming Languages » PHP » PHP image upload script in IE7


PHP image upload script in IE7

Reply
  #1 (permalink)  
Old 02-21-07, 12:52 PM
jac2703's Avatar
jac2703 jac2703 is offline
Newbie Coder
 
Join Date: Jan 2006
Posts: 99
Thanks: 0
Thanked 0 Times in 0 Posts
PHP image upload script in IE7

Hello all,

I am back again to question you PHP wizards. My PHP is slowly coming along however i fear it may be my HTML at fault this time.

I have an image upload script, with code as below, which performs a few simple checks and then save the image:

PHP Code:

  $ext substr(basename$_FILES['upfile']['name']), strrpos(basename$_FILES['upfile']['name']), '.') + 1);


  if((
$ext == "jpg") && ($_FILES["upfile"]["type"] == "image/jpeg")) {
    
$clean true ;
  }
      
  elseif((
$ext == "png") && ($_FILES["upfile"]["type"] == "image/png")) {
    
$clean true ;
  }

  elseif((
$ext == "gif") && ($_FILES["upfile"]["type"] == "image/gif")) {
    
$clean true ;
  }

  else {
     
$clean false ;
    
//not an acceptable file type
  
}

  if(
$clean == true) {
    
//more checks
    //save image
  

and a HTML form to input the data:

PHP Code:

<form action="{FULL_URL}/account.php?content=upload" method="post" enctype="multipart/form-data" name="form1" class="style1" id="form1">

  <
input type="hidden" name="MAX_FILE_SIZE" value="999999999" />
  <
input name="upfile" type="file" size="55" />
</
form
Now this seems to work fine in Firefox 3 however not in IE7. The image is not uploded as the uploaded file (eg. example.png) does not meet one of the first three 'if' statments and is therefore accepted by the 'else { $clean = false ;...'

Now as PHP is server side i cant see how it could be the PHP to fault, or is it?

Thank you for your time

James
__________________
JamesCoyle.net Blog and Network tools.
Reply With Quote
  #2 (permalink)  
Old 02-21-07, 01:58 PM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
Echo $_FILES["upfile"]["type"] to see what it actually contains.

You can also echo the entire $_FILES array to see what it contains -
PHP Code:

echo "<pre>";

print_r($_FILES);
echo 
"</pre>"
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
Reply With Quote
  #3 (permalink)  
Old 02-21-07, 05:38 PM
jac2703's Avatar
jac2703 jac2703 is offline
Newbie Coder
 
Join Date: Jan 2006
Posts: 99
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by mab View Post
Echo $_FILES["upfile"]["type"] to see what it actually contains.

You can also echo the entire $_FILES array to see what it contains -
PHP Code:

echo "<pre>";

print_r($_FILES);
echo 
"</pre>"
Well isnt that a nifty little function. That solved my problem straight away. IE7 uses:

PHP Code:

$ie7_jpeg $_FILES["upfile"]["type"] == "image/pjpeg"

$ie7_png $_FILES["upfile"]["type"] == "image/x-png" 
print_r() helped me solve 2 other problems i had. I wish i had read up on it when i saw it on php.net

Thanks mab!

James
__________________
JamesCoyle.net Blog and Network tools.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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 On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple PHP File Upload / Management Script LiNx88 Script Requests 2 11-02-07 08:07 PM
2 profitable script sites for sale cms-master.com General Advertisements 3 07-03-07 10:17 AM
php upload file script xavier039 PHP 5 08-29-06 04:35 PM
Raffle/Lottery Script (Very profitable!), Coded it myself. Voltaire General Advertisements 2 01-02-06 11:55 PM
Image Upload Perms automatically set to 600 progress Perl 2 10-05-05 12:19 PM


All times are GMT -5. The time now is 05:56 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.