Upload script works fine with IE, but no other browser...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
keith.welch
Forum Newbie
Posts: 1
Joined: Thu Sep 03, 2009 1:37 pm

Upload script works fine with IE, but no other browser...

Post by keith.welch »

I use this script to allow uploading of small text files from an Adobe Flex front end. For a change, it works fine in IE7 but not in any other other browser. I get no error message, but the page just hangs, and a 0 kb file is created in my target directory. Any suggestions would be gratefully appreciated.

OS: Vista
Server: Apache
authentication: .htaccess
the uploads are stored in a directory outside my web root. That folder permission is 700, although it doesn't seem to affect the problem


the script:

<?php
error_reporting(E_ALL);
$uploadFolder = "/ip/XXX/lhr/uploads/";
$logFile = fopen($uploadFolder."logfile.txt", 'a');
if (isset($_FILES['Filedata']['name']) && (isset($_ENV["REMOTE_USER"]))){
$tempFile = $_FILES['Filedata']['tmp_name'];
$suffix = substr($_FILES['Filedata']['name'], -4, 4);
$fileName = $_ENV["REMOTE_USER"].$suffix;
$fileSize = $_FILES['Filedata']['size'];
$dateStamp = date("F j, Y, g:i a");


if(!preg_match("/(\.txt)$/i", $fileName)) {
fwrite($logFile, $dateStamp." Invalid file type ".$fileName." ".$fileSize."\n");
fclose($logFile);
die ("Server: Upload failed: Invalid file type.");
}

if ($fileSize > 10000) {
fwrite($logFile, $dateStamp." File is too large ".$fileName." ".$fileSize."\n");
fclose($logFile);
die ("Server: Upload failed: max. file size = 10KB");
}
elseif ($fileSize == 0) {
fwrite($logFile, $dateStamp." Empty file ".$fileName." ".$fileSize."\n");
fclose($logFile);
die ("Server: Upload failed: Empty file");
}
else {
move_uploaded_file($tempFile, "$uploadFolder".$fileName);
fwrite($logFile, $dateStamp." Successful upload ".$fileName." ".$fileSize."\n");
die("Server: Upload successful.");
}
}
fclose($logFile);
?>
Post Reply