#1  
Old 9th December 2007, 06:12
bradhawk bradhawk is offline
Member
 
Join Date: Nov 2007
Posts: 35
Thanks: 1
Thanked 0 Times in 0 Posts
Exclamation PHP File Upload Problem

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:
Code:
<head>
<meta http-equiv="content-type" content="text/html"; charset="iso-8859-1" />
<title>Uploading Files...</title>
</head>
<body>
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL & ~E_NOTICE);

if(isset($_POST['submit']))
{
		echo "<pre>";
		print_r($_FILES);
		echo "</pre>";

	if(move_uploaded_file($_FILES['thefile']['tmp_name'], "Proposal/{$_FILES['thefile']['name']}"))
	{
		print '<p>Your file has been uploaded successfully!</p>';
	}
	else
	{
		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>';

		

		
		switch($_FILES['thefile']['error'])
		{
			case 1:
				print 'The file exceeds the upload_max_filesize setting in php.ini';
				break;
			case 2:
				print 'The file exceeds the MAX_FILE_SIZE setting in the HTML form';
				break;
			case 3:
				print 'The file was only partially uploaded';
				break;
			case 4:
				print 'No file was uploaded';
				break;
			case 6:
				print 'No temp directory found';
				break;
			case 7:
				print 'Cannot write file to specified location';
				break;
			case 8:
				print 'Extension not valid';
				break;
		}
		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" />
</p>
</form>
</body>
</html>
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!
Reply With Quote
Sponsored Links
  #2  
Old 10th December 2007, 08:04
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,744 Times in 2,577 Posts
Default

What's the output of the print_r($_FILES); line?
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #3  
Old 11th December 2007, 08:09
bradhawk bradhawk is offline
Member
 
Join Date: Nov 2007
Posts: 35
Thanks: 1
Thanked 0 Times in 0 Posts
 
Default

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.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Freebsd 6.1 support misterm Installation/Configuration 10 9th April 2009 09:29
Installations Problem @ PHP thryb Installation/Configuration 1 7th November 2007 13:41
php eating cpu shajazzi Server Operation 15 15th August 2007 01:19
Apache2 Freezes celtic Server Operation 31 28th May 2007 17:18
HotSaNIC domino Tips/Tricks/Mods 23 6th November 2006 05:19


All times are GMT +2. The time now is 07:40.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.