Jump to content

Uploading File Problem


konflikt

Recommended Posts

I am having trouble getting my upload file to work...

 

Form HTML:

<form action="" method="POST">
<input type="file" name="file" />
<input type='"submit" name="upload" value="Upload" />
</form>

 

PHP:

if($_POST["upload_avatar"]){
$upload_path = "images/users/";
$file = $_FILES["file"]["name"];
$extension_types = array("gif","jpg","jpeg","png");
if($file){
	$filename = stripslashes($_FILES["file"]["name"]);
	$extension = getExtension($filename);
	$extension = strtolower($extension);
	$size = filesize($_FILES["file"]["tmp_name"]);
	if(in_array($extension, $extension_types)){
		if($size <= $max_file_size){
			$file_search = glob($upload_path . strtolower($username) . '*');
			array_map("unlink", $file_search);

			$file_name = $upload_path . strtolower($username) . "." . $extension;
			$copied = copy($_FILES["file"]["tmp_name"], $file_name);
			if (!$copied){
				$r_error = "Upload has failed";
			}
		}
		else{$r_error = "File too big";}
	}
	else{$r_error = "Unknown file extension";}
}
else{$r_error = "No file chosen";}
}

 

Every time, it gives me the "No File Chosen" error.  It doesn't seem to be actually uploading the file... I hope this isn't just some stupid thing I am looking over, can someone help me?

 

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