I am currently working on a simple php website
The problem is , the images in my whole web site(happens in all php files) randomly corrupt and show the error
Resource interpreted as Image but transferred with MIME type text/html, however, if I try to refresh the page several times. The image can be loaded again and the error is gone.
I have checked all img path and the image is exist. Also, I checked there is no img src="" in my file. Is it due to server setting? I check .htaccess file and it is blank. How to fix the problem ? Thanks
One possible reason for this could be an intermittent server error, which serves an error page instead of the image resource.
Apache's access.log will tell you which response code the images were sent with (200 means "ok"). error.log will tell you the exact error message if you find an error.
This could also be the intermittent hick-up of a company or ISP proxy server.
Related
I am uploading more than 12 images files for a single requests but the online server refuses to upload those images. In my local machine it works fine, i can upload more than 20 images at once. I have configured the PHP settings for max_file_uploads = 60, upload_max_filesize=100M, post_max_size = 125M in php.ini, both on my local machine server and online server. While sending the page loads unfinishing, and at the end after a long time it responds with a Network Protocol Error, which says that:
"An error occurred during a connection to www.mydomain.com. The page you are trying to view cannot be shown because an error in the network protocol was detected."
See the screen shots of other different error responses i've also got after many trials, and it still takes a long time of loading to get those responses after sending.
The images that i am uploading are being saved on server but not all. When i upload 20 images for a single request, it can get only 8 or 10 and sometimes the last image is cut short(interrupted) before it is fully uploaded, see its picture below.
I need to get all the images i am uploading like in my local machine, and with a quick response. What else i can do for configuration in PHP or elsewhere? What's wrong on shared hosting server? Please, if you have any answer to this, you can tell me what i can do, to get all uploaded images files with a quick response.
It's clearly because of a timeout error. It's not acceptable to send multiple files with one request. Even if you get it to work right now, it will fail from time to time depending on the user connection speed and file size. Also you mentioned a quick response. So you definitely need to use ajax upload to upload files simultaneously. There are multiple upload libraries such as dropzone.
I'm using Codesleeve/asset pipeline on my Laravel project to serve css, js and image files. It on the whole works fine but there is an issue with displaying css-loaded images. The image does not display and shows the browser's "broken image" symbol when loading it directly (http://art.ipscap.com/assets/select2.png for example): e.g.
Upon inspecting the page it shows the image is loaded successfully with 200 OK status (or cached) but there seems to be an error displaying it. Seeing as the image in question displays fine on my local machine and the problem is only in production is there a way to diagnose this issue?
Edit: Still haven' t managed to find a solution for this. For reference the live broken image url is https://art.ipscap.com/assets/select2.png. The image itself is in app/assets/images/select2.png and the readme in the same directory states:
If you place an image here called foobar.png then you can access that image by going to http://<hostname>/assets/foobar.png
I find it strange as the image does not fail to load but is being broken by asset pipeline. The same does not seem to occur to other images in the app such as the header jpeg image.
Do you use different server software on your local and production server? I see the production uses nginx. In that case, you might have to add something to your config as stated here:
https://github.com/CodeSleeve/asset-pipeline#can-i-use-nginx
I'm running a project on a server which runs IIS 7.5
There's a strange error that I have never seen. The project is written with Codeigniter. I'm converting videos with ffmpeg.exe and writing the results in separate text files for each video. And in the client side it reads the text file for progress.
But the server throws a 404 error for existing txt file. It keeps throwing error until I restart the server. After restarting the server, it can be able to show the text file.
Everything else works perfect. Please help me.
EDIT:
.txt files are reachable after amount of time. But it's not certain how much time should pass.
I found a solution. This isn't a solution to the source of the problem but works for me.
I think, IIS was throwing the 404 error because the file is being processed and locked by ffmpeg. I was getting the file contents by file_get_contents() via HTTP address and it returns an empty string or error message. So I decided to use the physical address of the file and to use read_file() function with output buffering.
It's now working without any error.
We are getting plagued with this which started in April on working server. Everything was fine with our application until the customer reported that PDFs were no longer displaying the images.
Our PDF is generated via a HTML render first. When the HTML render is displayed the Image shows correctly. Also the image shows correctly if the image URL as noted in the mPDF is copied and pasted into a new tab.
However... If we load the image from a DIFFERENT DOMAIN then the image is rendered correctly. loading the image via absolute path, relative path or URL path all result in this error:
mPDF error: IMAGE Error (http://www.aibsonline.co.uk/logo.gif): Could not find image file
But, as you will see the logo url works when pasted. File permissions have been tested (which is why it is in the root) as standard and up to 777. Server is a Linux server in both cases we have seen so far.
HTML Code that renders the logo:
<div id="logo_wrapper" class="left">
<img width="107" height="76" src="<?php echo base_url('logo.gif'); ?>" />
</div>
At a real loss with this one and it is beginning to affect more and more clients.
Any help gratefully received.
UPDATE
The image renders if the rendering code and the image are in the same directory and we do NOT use an absolute path, eg.
<img width="107" height="76" src="logo.gif" />
I ran across this issue today. My problem was that the domain name I was using didn't resolve back to the server when accessed from the server. I added an entry to the hosts file on the server, and images started showing.
Your equivalent hosts file entry of what fixed my problem would be:
127.0.0.1 www.aibsonline.co.uk
Or otherwise ensure that www.aibsonline.co.uk resolves to your server in the DNS that your server uses.
It appears that mPDF accesses images as a cURL web client, so DNS on the server needs to be configured correctly to refer back to itself.
I had a similar issue and I solve by following:
1.Check if gd library is installed and enable in your php ini file. If not install gd library.
2.Turn on debug variable
$mpdf = new mPDF();
$mpdf->showImageErrors = true;
3.Try inter-changing absolute/relative path for the image
<img src="http://someDomain/directory/image.jpg">
<img src="./directory/image.jpg">
Hope this helps.
With same issue, I found that get_headers() returns:
"HTTP/1.1 412 Precondition Failed"
Provider says this was due to web firewall, because the request was badly formed and the user_agent not set.
An ini_set('user_agent', 'Mozilla/5.0'); solved the problem.
In a WordPress plugin using mpdf, mpdf doesn't use WordPress http classes and doesn't set user_agent. I solved this by adding in mu-plugins:
global $wp_version;
ini_set('user_agent',apply_filters( 'http_headers_useragent', 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) ));
I tried all other answers here but for me, only adding
$mpdf->curlAllowUnsafeSslRequests = true;
fixed the issue.
I was running into the same issue. mPDF was running DOG SLOW and would end up just displaying a "Cannot find image file" error. After
checking to make sure the image is actually there
checking the permissions on the file
checking all of the error logs on the server
combing through the documentation on mPDF
I found that the image file in question was corrupted somehow. I downloaded the image to my local computer, opened it up with an image editor (Paint.NET in this case), re-saved it as a .gif file and uploaded it to the server again. That seemed to fix it. Your mileage my vary.
Also, for what its worth, I had to use images/image.gif instead of the file path /images/image.gif.
Just make sure that you have image related functions in your PDF class file. Like parsejpg, parsepng, parsegif etc...
I have password protected server (.htaccess / .passwd) and after some research I understand that mPDF using HTTP to get the images, but server blocks the images from the public because of password protection.
After removing password protection I had ssl certificate issue, and I enable usafe requests and it starts working
$mpdf->curlAllowUnsafeSslRequests = true;
Also you can always enable debug modes and follow the error messages
$mpdf->showImageErrors = true;
$mpdf->debug = true;
In my site, I give an option to upload images with .jpg and .JPG extension. They both work and I can see both on the server itself.
When I try to see in the browser the photos with the .jpg extension by calling them name.jpg, they work. When I call to the othername.JPG (which is called that way on the server) it does not work and does not show it. othername.jpg does not work too.
I suppose your web server is not configured to send the Content-Type: image/jpeg HTTP header for such files. It's possible that some browsers refuse to display them as pictures if the MIME type does not match. If you happen to be using Apache, you can fix it yourself in an .htaccess file:
AddType image/jpeg .JPG
You should also consider that you cannot count of URLs being case-insensitive: FOO can equal foo... or not. Use always the exact case and save yourself future problems.
Edit:
Before misconfiguring random stuff, you can follow this checklist and see what fails exactly:
Is the URL valid? Foo.jpg is not the same as foo.jpg.
Does the browser receive the file? Firebug should tell you.
What's the HTTP response code? Firebug should tell you.
What's the Content-Type header? Firebug should tell you.
Common status codes:
404: the file could not be found. Most likely, your URL is wrong.
403: you are not authorised to see the file. It can be a permissions issue.
500: generic server error code. You should open your hosting service control panel and have a look at the error log.
Your using linux/apache right? make the filenames lowercase. its the default for them to be accessed on linux.
try to check the contents of that file, maybe your script is messing up JPG uploaded files.
if that doesn't work maybe it's from your system .. an .htaccess
Look in error logs for anything that is related to this file.