I recently migrated my webserver to a dedicated machine. It’s still Win32, but the paths changed a little. After much shenaningans from Apache 2.2, I finally got the server live, but my Upload only works on localhost. If I go to any other machine on the network or access the upload from the internet, it fails with the error “Warning: copy() [function.copy]: Filename cannot be empty in G:\HTTPROOT\uploader.php on line 20”.
The upload control portion of the script is as follows:
[php]$uploaddir = “G:\HTTPROOT\uploads\”;
$path = $uploaddir.$SafeFile;
$upload_err = $_FILES[‘uploaded_file’][‘error’];
echo <<<FANCY
FANCY;if($uploaded_file != none){ //AS LONG AS A FILE WAS SELECTED…
if(copy($_FILES['uploaded_file']['tmp_name'], $path)){ //IF IT HAS BEEN COPIED...
//GET FILE NAME
$theFileName = $_FILES['uploaded_file']['name'];
//GET FILE SIZE
$theFileSize = $_FILES['uploaded_file']['size'];
if ($theFileSize>999999){ //IF GREATER THAN 999KB, DISPLAY AS MB
$theDiv = $theFileSize / 1000000;
$theFileSize = round($theDiv, 1)." MB"; //round($WhatToRound, $DecimalPlaces)
} else { //OTHERWISE DISPLAY AS KB
$theDiv = $theFileSize / 1000;
$theFileSize = round($theDiv, 1)." KB"; //round($WhatToRound, $DecimalPlaces)
}
echo <<<UPLS
Upload Successful | |
File Name: | $theFileName |
File Size: | $theFileSize |
} else {
//PRINT AN ERROR IF THE FILE COULD NOT BE COPIED
echo <<<UPLF
File "$SafeFile" could not be uploaded: Error: $php_errormsg |
If it works, I should get the following report (example is using my test file):
Upload Successful
File Name: Sunset.jpg
File Size: 71.2 KB
But why does it only work on localhost? What am I missing?