1

I have some problem using getimagesize(). After uploading a file, the latter is put . But when I call getimagesize() (or fopen()), I get this error message

getimagesize(http://mysite.com/files/documents/file_upload.png) [function.getimagesize]: failed to open stream: HTTP request failed! HTTP/1.1 404

When I put this URL in the browser, the image displays normally.

user1611830
  • 4,749
  • 10
  • 52
  • 89
  • Keep in mind that `getimagesize` does it's own request and the server might return a different response if it doesn't see a browser (client) that it recognizes, to avoid bots and such. – Halcyon Dec 23 '12 at 23:17
  • 1
    It looks like you already found the solution, just request the image with your browser, then store it on your server and then ... :) - check for request headers. – hakre Dec 23 '12 at 23:17
  • Sorry , I don't understand because I have used it many times and it worked perfectly. So what should I do because it is really a normal upload process? hould I check for permissions ? – user1611830 Dec 23 '12 at 23:19
  • Do the request with your browser but take a look which request headers are send. Then add the same request headers to the HTTP context options to `fopen`. It then normally works. – hakre Dec 23 '12 at 23:20
  • sorry, I am quite a newbie, I found that what should I do with Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3 Accept-Encoding:gzip,deflate,sdch Accept-Language:en,fr-FR;q=0.8,fr;q=0.6,en-US;q=0.4 Connection:keep-alive – user1611830 Dec 23 '12 at 23:28
  • Same problem, includes a working solution: [php getimagesize not working][1] [1]: http://stackoverflow.com/questions/25230949/php-getimagesize-not-working?answertab=votes#tab-top – phil294 Aug 10 '14 at 19:33

1 Answers1

1

Contact the server owner where you want to request the image and ask what the technical requirements are to obtain the image. The owner will tell you what you have to do or if it is generally not supported to request images with a PHP script like you do.

However only the server owner can tell you. HTH.

hakre
  • 193,403
  • 52
  • 435
  • 836