问题
I have a strange problem. I have an image which i need to upload to a file server. I 'm using php to do this. The image permissions are the following
-rw-r--r--. 1 apache apache 148041 Dec 22 08:25 Not.jpg
I checked that the file exists. I have downloaded the file and found it to be ok. it's original size is 60 KB. Permissions are also fine.
When I do the following
$filepath = "../uploads/".$file_name;
$image = fopen($filepath, "rb");
echo file_exists($filepath).' ';
echo filesize($filepath). 'bytes ';
echo exif_read_data($filepath). ' ';
The output is
1 bytes 200
1 - File Exists
bytes - This is where the error occurs. filesize() is returning an empty string here
200 - server response
What is the correct way to load this file ?
回答1:
As reference to fopen manual of PHP the modes should be either read or write. You are using undefined mode rb. try using this
$image = fopen($filepath, "r");
来源:https://stackoverflow.com/questions/34429373/php-filesize-returns-an-empty-string