I am in need to use This Class to server multiple files (img/video/mp3) from an article writing site i use , the only and main problem is that :
All images in the articles should be displayed by that class , and that this class doesn’t show images (initiates a download when called by URL) .
I managed to fix that by deleting this line (maybe line 107)
header('Content-Disposition:attachment; filename="'.$this->properties["name"].'";');
which served me well in displaying images from chrome and firefox , but IE still initiate a download 🙁 .
is there any way / headers to fix that ?
Edit :
I added the following to the meta type :
case "jpg": $content_type="image/".$file_extension; break;
case "gif": $content_type="image/".$file_extension; break;
case "png": $content_type="image/".$file_extension; break;
With setting Content-Disposition to attachment is actually intended to be used not to display the resource directly:
But although the Content-Disposition header field is rather part of MIME and not part of HTTP, it “has been proposed as a means for the origin server to suggest a default filename if the user requests that the content is saved to a file.” (See HTTP/1.1 – 19.5 Additional Features)
Additionally to that, the use of the special media type application/octet-stream is recommended to imply a download:
But since you want to resource to be displayed directly, use the Content-Disposition value inline instead. With this you can use the filename parameter as well to specify a file name different from the URL’s.
See also Julian Reschke’s Test Cases for HTTP Content-Disposition header field and the Encodings defined in RFC 2047 and RFC 2231/5987 for some further information on the encodings used to encode the filename parameter.