Hooch Posted December 29, 2006 Share Posted December 29, 2006 Hello all. I hope Santa was good to all. I am starting to update a site I volunteer for. The site has been totally updated by myself, but I am wanting to make it more user friendly so the members can upload and manage their own info. Here is my upload script. Firefox uploads perfectly. But IE says it's trying to upload a wrong file. But it is actually the .jpg that Firefox successfully uploaded earlier. Hmm.. Is there something I am missing here?? Here is the code.. <?phpob_start(); session_start(); include("config.php"); //include("online.php");if($logged[username]){$a = $_POST['picture']; if ($a == 0) { echo "<link href=\"style.css\" rel=\"stylesheet\" type=\"text/css\" />"; echo "<center><br><br>Please define where the picture is to go. <br><a href=\"upload.php\" class=\red-medium-14\">Click to go back</a></center>"; } else { $upload_dir = "../images/users/"; $size_bytes = 1048576; $limit_file_type = "yes"; $allowed_file_type = array('image/jpeg', 'image/jpg'); $size = $_FILES['file']['size']; if ($size > $size_bytes) { echo "<link href=\"style.css\" rel=\"stylesheet\" type=\"text/css\" />"; echo "<br><center>File is Too Large. It must be <b>$size_bytes</b> bytes, or less.<br>"; echo "<a href=\"upload.php\" class=\red-medium-14\">Back</a></center>"; exit(); } if (($limit_file_type == "yes") && (!in_array($_FILES['file']['type'],$allowed_file_type))) { echo "<link href=\"style.css\" rel=\"stylesheet\" type=\"text/css\" />"; echo "<br><center>Wrong file type.<br>"; echo "<a href=\"upload.php\"class=\red-medium-14\>Back</a></center>"; exit(); } $path = $upload_dir."/".$logged['username']."/pic".$a.".jpg"; if($file !=none) { if(copy($HTTP_POST_FILES['file']['tmp_name'], $path)) { echo "<link href=\"style.css\" rel=\"stylesheet\" type=\"text/css\" />"; echo "<center><BR><BR><b>Success</b><BR/>"; echo "<a href=\"../login.php\"class=\"red-medium-14\">CPanel</a><BR/><BR/>"; echo "File Size :".$HTTP_POST_FILES['file']['size']." bytes<BR/><BR/>"; echo "<img src=\"$path\"><br/></center>"; } else { echo "Error "; echo ("<a href=\"upload.php\" class=\"red-medium-14\">Back</a></center>"); } }}}else{echo "<link href=\"style.css\" rel=\"stylesheet\" type=\"text/css\" />";echo "<br><center><b>You must be logged in!!</b><br>";echo "<a href=\"../index.php\" class=\"red-medium-14\">Back</a></center>";}?> Thank you for any help. Link to comment Share on other sites More sharing options...
yoshida Posted December 30, 2006 Share Posted December 30, 2006 That's some nifty scripting. I might want to hawk that if I may. :)Are you sure the extension of that file is lowercase? Most servers are case sensitive, but I don't know how that works in this situation. You might want to include uppercase exensions in your array, and certain combo's of upper - and lowercase. Link to comment Share on other sites More sharing options...
Hooch Posted December 30, 2006 Author Share Posted December 30, 2006 Thanks yoshida, I'll give it a try.I did not make the whole code myself. It is stuff I have learned from multiple sitesmulled together to fit my needs. Feel free to use it though....it's nice to hear someonecompliment my work. Hooch Link to comment Share on other sites More sharing options...
Hooch Posted January 2, 2007 Author Share Posted January 2, 2007 I added the capitol extension for the jpegs. Still a no go. $allowed_file_type = array('image/jpeg', 'image/JPEG', 'image/jpg', 'image/JPG'); IE still says my_pic.jpg is the wrong file type.Anyone know what is going on here?P.S Is this line ok? if (($limit_file_type == "yes") && (!in_array($_FILES['file']['type'],$allowed_file_type))) Link to comment Share on other sites More sharing options...
jesh Posted January 2, 2007 Share Posted January 2, 2007 I don't know that this will help, but you might try adding "image/pjpeg" to your list of MIME types. That's saved me a number of times.You might also echo out the MIME type that IE sends with the file to see why "Wrong file type." is displayed. Link to comment Share on other sites More sharing options...
justsomeguy Posted January 3, 2007 Share Posted January 3, 2007 I don't know that this will help, but you might try adding "image/pjpeg" to your list of MIME types. That's saved me a number of times.That is correct. For whatever reason, IE sends the mime type of a jpeg as image/pjpeg. Which is different from everything else. Thanks, Microsoft! Link to comment Share on other sites More sharing options...
Hooch Posted January 3, 2007 Author Share Posted January 3, 2007 That was it guys. Thank you very much. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now