I have thousands of image urls stored in a table, one per row. The thing is that some of them have bad formatted names with spaces, accented characters, etc, ie like this:
https://www.greatsite.com/upload/memdocs/111046-carte d'identit� 001-072716141540.jpg
When opening this url in a browser, the following error is output:
Not Found
The requested URL /upload/memdocs/111046-carte d'identit� 001-072716141540.jpg was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
I need to programatically find all the image urls that throw this "Not Found" error (in order to later correctly format the image url name).
So far I am trying to use getimagesize() and file_get_contents() but no luck. getimagesize() not always work because I think it kind of fixes the image name, because for example for the url above, it actually does returns and array with the image info. And file_get_contents() always returns something regardless of wether the image url throws the "Not Found" error or not.
Any suggestions on how I could accomplish this? I hope I made sense. Thanks