Jump to content

Upload script


millercj

Recommended Posts

I'm building an upload script which is below but i'm getting the following error:

 

PHP Warning:  move_uploaded_file(/done) [<a href='function.move-uploaded-file'>function.move-uploaded-file</a>]: failed to open stream: Permission denied in /home/digiconm/public_html/recorded-live/upload/file/go.php on line 53

 

PHP Warning:  move_uploaded_file() [<a href='function.move-uploaded-file'>function.move-uploaded-file</a>]: Unable to move '/var/tmp/php8T3pEA' to '/done' in /home/digiconm/public_html/recorded-live/upload/file/go.php on line 53

 

I know what it means and why but how do I overcome this?

 

go.php

<?
if ($_FILES['Filedata']['name'] && ($log = fopen('./upload.log', 'a') ) )
{
	$file = $_FILES['Filedata']['tmp_name'];
	$error = false;

	/**
	 * THESE ERROR CHECKS ARE JUST EXAMPLES HOW TO USE THE REPONSE HEADERS
	 * TO SEND THE STATUS OF THE UPLOAD, change them!
	 *
	 */

	if (!is_uploaded_file($file) || ($_FILES['Filedata']['size'] > 2 * 1024 * 1024) )
	{
		$error = '400 Bad Request';
	}
	if (!$error && !($size = @getimagesize($file)))
	{
		$error = '409 Conflict';
	}
	if (!$error && !in_array($size[2], array(1, 2, 3, 7,  ) )
	{
		$error = '415 Unsupported Media Type';
	}
	if (!$error && ($size[0] < 25) || ($size[1] < 25))
	{
		$error = '417 Expectation Failed';
	}
	//write log

	fputs($log, ($error ? 'FAILED' : 'SUCCESS') . ' - ' . gethostbyaddr($_SERVER['REMOTE_ADDR']) . ": {$_FILES[Filedata][name]} - {$_FILES[Filedata][size]} byte \n" );
	fclose($log);

	if ($error)
	{
		//ERROR DURING UPLOAD, one of the validators failed
		header('HTTP/1.0 ' . $error);
		die('Error ' . $error);
	}
	else
	{
		// UPLOAD SUCCESSFULL AND VALID

		 move_uploaded_file($file,"/done");

	}

	die('Upload Successfull');

}
?>

 

Link to comment
https://forums.phpfreaks.com/topic/102029-upload-script/
Share on other sites

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.