Jump to content

Works fine on my server, but does not work on customers


cnl83

Recommended Posts

I uploaded this small app to my server, and it works fine. I uploaded to my customers server, and it does not work. Im not sure what to ask the host to turn on or off. Maybe someone here has had this problem.

 

Here is the error

Warning: copy(/home/content/k/e/v/kevinandjeff/html/allsaidaudiosolutions/uploads/uploads/): failed to open stream: Is a directory in /home/content/k/e/v/kevinandjeff/html/allsaidaudiosolutions/uploads/upload.php on line 18

 

Here is PHP

<?php

$path = dirname($_SERVER['SCRIPT_FILENAME']) . "/uploads";

//If we are sending a file.
if(isset($_FILES['file']) == true)
{
//Change scope of file var.
$file = $_FILES['file'];
//Down below after the code $path  is where you add 
//to the name of the image such as imagespotlight
if(copy($_FILES['file']['tmp_name'], $path . "/" . $file_name) == true)
{
	//Create a linker thing! Also is where the link is actually put out.
	//In order to give correct link you have to be in concert with the above statement like
	//spotlight --> then the actual jpg, but you have to add spotlight so the link can be correct.
	$file_url = "http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/uploads/" . $file_name;

	//Create a good message!
	$message = "<font color=\"green\">Your {$kbsize}KB file named <i>$file_name</i> was uploaded successfully.</font><br>\n"
		. "<b>File <a href=\"" . $file_url . "\">Link:</a></b><br>\n"
		. "<textarea readonly cols=\"50\" rows=\"1\">" . $file_url .  "</textarea>\n";

//If the copy fails.
}
else
{
	//Create error message!
	$message = "<font color=\"#990000\">Error - Your  file named <i>$file_name</i> was not uploaded successfully.</font>";
}

//Unlink the temp file.
unlink($_FILES['file']['tmp_name']);
}

//Output message.
echo $message;
?>

$file_name (used in the copy() destination) does not appear to be set anywhere.  Is this passed in via form?

 

If so, you can fix it by replacing $file_name with $_REQUEST['file_name'], in both locations it appears.  And the cause will be that register_globals is switched off on your customer's server.

First make sure that uploads dir is writable by your apache user.

 

You can eliminate a lot of your complexity by using relative file names.

 

You do this:

//Change scope of file var

$file = $_FILES['file'];

But I don't see you reference $file anywhere and $_FILES is global anyhow so there's no need.

 

 

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.