Problem with Upload script

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
Return home. UPLS;
} else {

//PRINT AN ERROR IF THE FILE COULD NOT BE COPIED
echo <<<UPLF

File "$SafeFile" could not be uploaded:
Error: $php_errormsg
Return home. UPLF; } } ?>[/php] For reference, Line 20 in my script is the one that reads as follows: [php]if(copy($_FILES['uploaded_file']['tmp_name'], $path)){ //IF IT HAS BEEN COPIED...[/php]

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?

OK, I don’t know what I did, but it’s fixed now.

I think you have changed the path $uploaddir = “G:\HTTPROOT\uploads\”; :slight_smile: 8)

No, I didn’t change the script. I was however playing around with my PHP.INI a bit, though I didn’t keep track of the things I did to it.

Sponsor our Newsletter | Privacy Policy | Terms of Service