Jump to content

Upload script works with IE7 but not with FF3, Safari or Chrome 2


Keith.Welch

Recommended Posts

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.

 

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/libcasd/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);

?>

 

Your code is dependent on $_ENV["REMOTE_USER"] to do anything. Have you checked what it actually contains?

 

In this case, it contains the username of the .htaccess authenticated user.  But it is a point - I'll check that variable content.

 

Thanks

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.