NeTech-UK Posted November 6, 2008 Share Posted November 6, 2008 Hi all, alas my first post be a problem I have been working on an image upload script and so far it all seems to be working.... in firefox. Problem is as soon as I attempt an upload in internet explorer the file handler errors out and defines the file as an unsupported upload. Cross browser compatibility is of course very important in this script. http://portfolio.netech-uk.com/imageupload I enclose the code for my file handler. any help would be appreciated... filehandler.php <?php $baseurl = "http://portfolio.netech-uk.com/imageupload"; $description = $_POST['description']; if (!($description)) { $description = "No Description"; } $description = nl2br($description); //Error #1: No File Specified //Error #2: File Already Exists //Error #3: Unspecified Error Occured //Error #4: Invalid File Specified //check that we have a file include 'includes/configandconnect.php'; if((!empty($_FILES["uploaded_file"])) && ($_FILES['uploaded_file']['error'] == 0)) { //Check if the file is JPEG image and it's size is less than 1Mb $filename = basename($_FILES['uploaded_file']['name']); $ext = substr($filename, strrpos($filename, '.') + 1); if (($_FILES["uploaded_file"]["type"] == "image/jpeg") && ($_FILES["uploaded_file"]["size"] < 1024000)) { //Determine the path to which we want to save this file $newname = dirname(__FILE__).'/files/'.$filename; $link = "$baseurl/files/$filename"; $filesize = $_FILES["uploaded_file"]["size"]; $filetype = $_FILES["uploaded_file"]["type"]; $uploaderip = $_SERVER['REMOTE_ADDR']; $date = date("l jS F Y"); $time = date("H:i"); //Check if the file with the same name is already exists on the server if (!file_exists($newname)) { //Attempt to move the uploaded file to it's new place if ((move_uploaded_file($_FILES['uploaded_file']['tmp_name'],$newname))) { mysql_query("INSERT INTO imageupload_images VALUES('', '$filename', '$filesize', '$date', '$time', '$ext', '$link', '$description', '$uploaderip')"); $getdata = mysql_query("SELECT * FROM imageupload_images WHERE filename = '$filename'"); while ($data = mysql_fetch_array($getdata)) { $id = $data['id']; } include 'includes/disconnect.php'; Header("Location: result.php?id=$id"); } else { include 'includes/disconnect.php'; Header("Location: result.php?status=3"); } } else { include 'includes/disconnect.php'; Header("Location: result.php?status=2"); } } else { include 'includes/disconnect.php'; Header("Location: result.php?status=4"); } } else { include 'includes/disconnect.php'; Header("Location: result.php?status=1"); } ?> Link to comment https://forums.phpfreaks.com/topic/131642-solved-upload-script-platform-issues/ Share on other sites More sharing options...
rhodesa Posted November 6, 2008 Share Posted November 6, 2008 well...instead of doing doing the redirect, echo the value of $_FILES["uploaded_file"]["type"] so you can see what it is...my guess is it's image/pjpeg Link to comment https://forums.phpfreaks.com/topic/131642-solved-upload-script-platform-issues/#findComment-683746 Share on other sites More sharing options...
NeTech-UK Posted November 6, 2008 Author Share Posted November 6, 2008 Thank you so much rhodesa, the problem was exactly what you thought it was Link to comment https://forums.phpfreaks.com/topic/131642-solved-upload-script-platform-issues/#findComment-683752 Share on other sites More sharing options...
rhodesa Posted November 6, 2008 Share Posted November 6, 2008 yeah...IE is stupid and uploads stuff as a "Progressive JPEG"....if you want to make your script a little more flexible it should be safe to just check the first part of the mime-type to see if it's an 'image' or not. Another way to check (GD needs to be supported) is to use getimagesize(). If it returns false, it's not a supported image. Link to comment https://forums.phpfreaks.com/topic/131642-solved-upload-script-platform-issues/#findComment-683760 Share on other sites More sharing options...
NeTech-UK Posted November 6, 2008 Author Share Posted November 6, 2008 thanks for the workaround, i think i'm gonna like it here at phpfreaks lol Link to comment https://forums.phpfreaks.com/topic/131642-solved-upload-script-platform-issues/#findComment-683763 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.