I'm making a multiple images upload system in php. This is what I have:
PHP
foreach($_FILES['files']['tmp_name'] as $key => $name_tmp)
{
$name = $_FILES['files']['name'][$key];
$tmp_name = $_FILES['files']['tmp_name'][$key];
$type = $_FILES['files']['type'][$key];
$size = $_FILES['files']['size'][$key];
$image = addslashes(file_get_contents($name));
$query2 = mysql_query("INSERT INTO afbeeldingen(naam, afbeelding) values ('$name', '$image')");
}
HTML
<input type="file" name="files[]" multiple>
Now if I add one or more files via the input form, I get the following error:
Warning: file_get_contents(download (1).jpg): failed to open stream: No such file or directory in D:\Apps\Xampp\htdocs\el_gusto\toevoegen_handler.php on line 578
What I'm I doing wrong? I'm only inserting the name & image for now.
Thanks in advance and taking time to read this!
Kind Regards
Use $tmp_name
when calling file_get_contents()
. This is the actual location of the file on disk until the end of the request. $name
contains the original name of the uploaded file in case you need it.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments