Jump to content

file upload


zetcoby

Recommended Posts

hello, i have a small problem with my file upload script, for some reason the file size or and the file extensions conditions wont work, and i don`t know why,

everything else works fine, if i wanna upload a file that has the right size it will upload, or if i upload a php file this one will upload too, i dont know why the condition wont kick in

if (isset($_FILES['file'])){

				 $target = "../../uploads/"; 
				 $rand = rand(1, 9999);
				 $target = $target . $rand . basename( $_FILES['file']['name']) ; 
				 $file_size = $_FILES['file']['size'];
				 $file_ext = strtolower(end(explode('.', $_FILES['file']['name'])));
				 if ($file_size >= 12000000) {
				 	header("Location: ../files/post?error=2&cid=".$cid);
				 }
				 if ($file_ext == 'php') {
				 	header("Location: ../files/post?error=3&cid=".$cid);
				 }
				move_uploaded_file($_FILES['file']['tmp_name'], $target);
			}

Link to comment
https://forums.phpfreaks.com/topic/266585-file-upload/
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.