Jump to content

Difference between XP and Vista files when uploading a file with PHP???


spikypunker

Recommended Posts

Hey Guys, am currently developing a small user generated content site, have been helped with some things already on here in the last few days.

 

I've got an annoying glitch thats come up during the testing phase. I've got an image uploader for the profile image and also a file uploader for uploading tracks. These are all working fine normally, and i thought i was out of the woods. But during the testing it's come apparent that for some computers neither file uploader is working! There's a bunch of tests in the PHP code, checking the file size, type etc and it's bringing up the Error message from the first check, Incorrect file type.

 

I've come to realise that the computers that this is happening on are running XP and the ones that have worked are running Vista, anyone seen this before??

 

Heres the code!

 

Also it would be sweet if i could know how to make this accept GIFS too??

 

:)

 

 

<?php

$user = $_GET['user'];





if((!empty($_FILES["uploaded_file"])) && ($_FILES['uploaded_file']['error'] == 0)) {
  
  $filename = basename($_FILES['uploaded_file']['name']);
  $ext = substr($filename, strrpos($filename, '.') + 1);
  if (($ext == "jpg") && ($_FILES["uploaded_file"]["type"] == "image/jpeg") && 
    ($_FILES["uploaded_file"]["size"] < 100000000)) {
    
      $newname = dirname(__FILE__).'/netdog/userpics/'.$filename;




      if (!file_exists($newname)) {
        
        if ((move_uploaded_file($_FILES['uploaded_file']['tmp_name'],$newname))) {
          
	  
	  
	  
	   mysql_connect ("localhost","maddogma_netdog","mightyb00sh");
		@mysql_select_db("maddogma_netdog") or die ("unable to connect");




		$query = " UPDATE USER SET image = '$filename' WHERE user='$user' ";

		mysql_query($query);

		mysql_close();


		echo "<meta http-equiv=\"refresh\" content=\"0;URL=profile.php?user=$user\">";




        } else {
           echo "Error: A problem occurred during file upload!";
        }
      } else {
         echo "Error: File ".$_FILES["uploaded_file"]["name"]." already exists";
      }
  } else {
     echo "Error: Only .jpg images under 350Kb are accepted for upload";
  }
} else {
echo "Error: No file uploaded";
}
?>

 

 

Peace!

Different browsers and versions of browsers (at least IE browsers) send a different mime types for the same file.

 

In your error checking and the messages you display when an test fails, echo out the value that was actually being tested so that you have immediate feedback as to why the test failed.

 

Edit: and there seems to be an echo in here, because I already posted the same information in one of your other threads - http://www.phpfreaks.com/forums/index.php/topic,234304.msg1088152.html#msg1088152

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.