Hi!

Does anyone know how to upload files? I already made the form.

Thanks!

$file = $_FILES["file"];
// set the file type you will allow to avoid abuse to your server
$accept = array('pdf','doc','xls','ppt','txt','zip');
if($file["size"] > 0) { 
$file_name = basename($file["name"]);
$ext = substr($file_name, -3, 3);

// validate file
if ($file["size"] > 500000) { 
  echo "Filesize over 500 KB limit.<br>\n"; 
}
elseif(!in_array($ext, $accept))  { 
  echo "Invalid file format. <br>\n"; 
} 
else {
  // set folder path to which image uploaded 
  $uploaddir = "/foldername/"; 
  //copy the file to some permanent location 
  if (move_uploaded_file($file['tmp_name'], $uploaddir.$file['name'])) {
	echo $file['name']." uploaded.<br>\n";
  } 
else {
	echo "Error found. Please try again. <br>\n";
  }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.