Jump to content

Code looks like its working but not producing the expected results


aeroswat

Recommended Posts

Here's the code

 

	if (($_FILES["ufile"]["type"] == "text/x-sql") && ($_FILES["ufile"]["size"] < 5000000)) {
	if ($_FILES["ufile"]["error"] > 0)
	{
		echo "Return Code: " . $_FILES["ufile"]["error"] . "<br />";
	}else {
		echo "Upload: " . $_FILES["ufile"]["name"] . "<br />";
		echo "Type: " . $_FILES["ufile"]["type"] . "<br />";
		echo "Size: " . ($_FILES["ufile"]["size"] / 1024) . " Kb<br />";
		echo "Temp file: " . $_FILES["ufile"]["tmp_name"] . "<br />";
		if (file_exists("../backups/" . $_FILES["ufile"]["name"]))
		{
			echo $_FILES["ufile"]["name"] . " already exists. ";
		}else {
			move_uploaded_file($_FILES["ufile"]["tmp_name"],
			"../backups/" . $_FILES["ufile"]["name"]);
			echo "Stored in: " . "../../backups/" . $_FILES["ufile"]["name"];
		}
	}
}else {
	echo $_FILES["ufile"]["type"] . ' ' . $_FILES["ufile"]["name"];
	echo " is an invalid file";
}

 

I have a upload file form that works with this and this code transfers the file to a permanent directory that is 2 levels above the file that is invoking the script. The first time I ran it with one of my files it gave me this as an output

 

Upload: Vincent_orders_02_02_2010_04-49PM.sql

Type: text/x-sql

Size: 675.7578125 Kb

Temp file: /tmp/phpUVSTze

Stored in: ../../backups/Vincent_orders_02_02_2010_04-49PM.sql

 

The next time I ran it showed me this

 

Upload: Vincent_orders_02_02_2010_04-49PM.sql

Type: text/x-sql

Size: 675.7578125 Kb

Temp file: /tmp/php6fGPyv

Vincent_orders_02_02_2010_04-49PM.sql already exists.

 

Woohoo it works right? Well I go into the backups folder and there are absolutely no files in there <_< The directory structure is like this

 

Top Level -> Backups (This is where I'm trying to transfer the uploaded file)

Top Level -> Public_html -> maint (This is where the php file is located)

 

Can anyone see anything obvious?

 

EDIT: I should also mention that backups has (777) attributes and that when move_uploaded_files is given a directory that doesn't exist it throws an error stating that.

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.