我試圖從遠程URL獲取圖像的文件大小,我想這就像這樣:腓 - 獲取文件大小與URL
$remoteUrl = $file->guid;
//remote url example: http://myApp/wp-content/uploads/2017/05/Screen-Shot-2017-05-08-at-10.35.54.png
$fileSize = filesize($remoteUrl);
但是,我得到:
文件大小():統計失敗 http://myApp/wp-content/uploads/2017/05/Screen-Shot-2017-05-08-at-10.35.54.png
HTTP不是一個文件系統。您需要從該URL下載內容(使用類似CURL的內容)並檢查下載內容的大小。 – David
[獲取遠程文件大小]的可能副本(https://stackoverflow.com/questions/27816849/get-size-of-a-remote-file) – alanlittle
請參閱[本主題](https:// stackoverflow。 com/questions/2602612/php-remote-file-size-without-downloading-file) 它建議捲曲這個任務。 –