I am trying to upload a jpeg image on a website i am working on but keep receiving the following error:
Warning: fopen() expects parameter 1 to be string, array given in /home/speedycm/public_html/speedyautos/carphoto.php on line 47
Warning: filesize() [function.filesize]: stat failed for Array in /home/speedycm/public_html/speedyautos/carphoto.php on line 48
Warning: fread(): supplied argument is not a valid stream resource in /home/speedycm/public_html/speedyautos开发者_StackOverflow中文版/carphoto.php on line 48
Warning: fclose(): supplied argument is not a valid stream resource in /home/speedycm/public_html/speedyautos/carphoto.php on line 49
the file carphoto.php has the following code on lines 47-49
$fp = fopen($_FILES["pics"]["tmp_name"], 'rb');
$contents = fread($fp, filesize($_FILES["pics"]["tmp_name"]));
fclose($fp);
This is usually because you're using multiple file uploads in your html form and using an array to group them together. Like:
<input type="file" name="pics[]"> ...
So php groups these tmp_files into an array accordingly.
You'll probably want to reference them individually
foreach($_FILES["pics"]["tmp_name"] as $file) {
....
}
精彩评论