PHP File Upload Problem

Discussion in 'Programming/Scripts' started by bradhawk, Dec 9, 2007.

  1. bradhawk

    bradhawk New Member

    Hi I'm trying to write a php script that will upload files to the server.

    I do have ISPConfig installed but I think that I've changed things in the necessary areas to not have problems with ISPConfig.

    Here is the script:
    <meta http-equiv="content-type" content="text/html"; charset="iso-8859-1" />
    <title>Uploading Files...</title>
    ini_set('display_errors', 1);
    error_reporting(E_ALL & ~E_NOTICE);
    		echo "<pre>";
    		echo "</pre>";
    	if(move_uploaded_file($_FILES['thefile']['tmp_name'], "Proposal/{$_FILES['thefile']['name']}"))
    		print '<p>Your file has been uploaded successfully!</p>';
    		print '<p>Your file could not be uploaded because: <b><br>';
    		print 'Temp Name: ';
    		print "{$_FILES['thefile']['tmp_name']}";
    		print '<br>';
    		print 'Name: ';
    		print "{$_FILES['thefile']['name']}";
    		print '<br>';
    			case 1:
    				print 'The file exceeds the upload_max_filesize setting in php.ini';
    			case 2:
    				print 'The file exceeds the MAX_FILE_SIZE setting in the HTML form';
    			case 3:
    				print 'The file was only partially uploaded';
    			case 4:
    				print 'No file was uploaded';
    			case 6:
    				print 'No temp directory found';
    			case 7:
    				print 'Cannot write file to specified location';
    			case 8:
    				print 'Extension not valid';
    		print '</b></p>';
    <form name = "uploader" method = "post" action = "Upload.php" enctype = "multipart/form-data">
    <p>Upload a file using this form: <br/><br/>
    <input type = "hidden" name = "MAX_FILE_SIZE" value = "3000" />
    <input type = "file" name = "thefile" /><br/><br/>
    <input type = "submit" name = "submit" value = "Upload File" />
    When I run this I have the error 6 come up. The error that says there is no temporary directory. Also the $_FILES['thefile']['tmp_name'] value is empty.

    I don't know what I'm doing wrong. The temporary directory has permissions 777 and I've set the temporary directory. I've looked through php.ini and can't see any problems. Anyone have any suggestions? Thanks!
  2. falko

    falko Super Moderator ISPConfig Developer

    What's the output of the print_r($_FILES); line?
  3. bradhawk

    bradhawk New Member

    I fixed the problem by changing the upload_tmp_dir from /var/www/phptemp to /tmp. Don't know what it didn't work with the other directory.

Share This Page