Jump to content

Recommended Posts

Here is the full code:

 

// Run the shit...

if($filesize > $_POST['MAX_FILE_SIZE']) {
	print_r($_FILES);
	die('The file you attempted to upload is too big!');
	}
if(!in_array($ext,$allowed_filetypes)) {
	print_r($_FILES);
	die('The file you attempted to upload is not allowed.');
	}

// If it is moved successfully, woot!

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path . $filename)) {
	echo "<font color='green'>The file ".  basename( $_FILES['uploadedfile']['name']).  " has been uploaded successfully!</font><br/>";
	echo "<b>File Size:</b> {$displaysize} KB <br/>";
	echo "<b>File Name:</b> {$_FILES['uploadedfile']['name']} <br/>";

// Check for password.

		if(empty($_POST['filepass'])) {
		echo "<p><i>No password specified.</i></p>";
		} else {
		$filepassed = $_POST['filepass'];
		echo "<p><i>File has been passworded successfully!</i></p>";
		}
	mysql_query("INSERT INTO files (username, filename, password, filesize, dllink) VALUES('$username', '$filename', '$filepassed', '$filesize', '$downloadlink') ")
	or die(mysql_error());
} else {
	print_r($_FILES);
    die('There was an error uploading the file, please try again!');
}
}

 

(Variables set above)

 

 

This is the error I get when uploading a file like, over 500kb or something:

Array ( [uploadedfile] => Array ( [name] => FileADB_CS2.zip [type] => [tmp_name] => [error] => 1 => 0 ) ) There was an error uploading the file, please try again!

 

I have tried many things. One guy said it was probably the server max file size set by the server (php.ini). I asked my host, they said it was set to 2500MB which is what it says in my CPanel. I even took the filesize checking code OUT and still same thing.

 

I need some help here. :(

Link to comment
https://forums.phpfreaks.com/topic/71752-error-1-size-0-uploading/
Share on other sites

My variables:

 

	$allowed_filetypes = array('.jpg','.gif','.bmp','.png','.rar','.zip','.doc','.mp3','.mpeg','.avi');
$max_filesize = $_POST['MAX_FILE_SIZE'];
$username = $_SESSION['username'];
$filename = ((int)rand(0,50)) . ($_FILES['uploadedfile']['name']);
$filesize = $_FILES['uploadedfile']['size'];
$displaysize = $_FILES['uploadedfile']['size'] / 100;
$ext = substr($filename, strpos($filename,'.'), strlen($filename)-1);
$target_path = "/home/myoosicn/public_html/upload/files/";
$_FILES['uploadedfile']['tmp_name'];
$folder = "http://upload.myoosic.net/download.php?file=";
$downloadlink = $folder . $filename;

 

The folder is CHMOD to 777 yes.

Hrm.. I would try FTPing into the temp directory and watch as the file is uploaded. Try a larger file so you can check the file size periodically, if all is well during the upload, then either the file is being removed before the script can move it, or their is a file path, or permissions error somewhere.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.