I have 2 upload file inputs in a form, how can I make web->receive function to work for 2 different upload paths depending on the file input name etc $_FILES['input_images'], $_FILES['input_documents'].
$f3->set('UPLOADS','uploads/'); // don't forget to set an Upload directory, and make it writable!
$overwrite = false; // set to true, to overwrite an existing file; Default: false
$slug = true; // rename file to filesystem-friendly version
$files = $web->receive(function($file,$formFieldName){
var_dump($file);
/* looks like:
array(5) {
["name"] => string(19) "csshat_quittung.png"
["type"] => string(9) "image/png"
["tmp_name"] => string(14) "/tmp/php2YS85Q"
["error"] => int(0)
["size"] => int(172245)
}
*/
// $file['name'] already contains the slugged name now
// maybe you want to check the file size
if($file['size'] > (2 * 1024 * 1024)) // if bigger than 2 MB
return false; // this file is not valid, return false will skip moving it
// everything went fine, hurray!
return true; // allows the file to be moved from php tmp dir to your defined upload dir
},
$overwrite,
$slug
);
Enter code here...