download link fails on non picture files #399

Closed
opened 2026-10-04 23:56:31 +02:00 by adam · 8 comments
Owner

The behavior of the download link is not correct on non picture files. Instead of going to action.php with a Content-Disposition: attachment, the url directly goes to the file. In case of an mp4, the video opens in the web browser, which is really not a "download".

@modus75 as far as my invistigation went, you changed that behavior on Piwigo 2.4. Was it "on purpose"?

The behavior of the download link is not correct on non picture files. Instead of going to action.php with a Content-Disposition: attachment, the url directly goes to the file. In case of an mp4, the video opens in the web browser, which is really not a "download". @modus75 as far as my invistigation went, you changed that behavior on Piwigo 2.4. Was it "on purpose"? <!-- github-sync-id:132456078 -->
adam closed this issue 2026-10-04 23:56:32 +02:00
Author
Owner

I don't remember the reason of the change. One explanation would be that I didn't like going through action for potentially large files and I'm pretty sure mp4 were not opening in the browser at that time...

I don't remember the reason of the change. One explanation would be that I didn't like going through action for potentially large files and I'm pretty sure mp4 were not opening in the browser at that time... <!-- github-comment-id:181937015 -->
Author
Owner

If the file transit via PHP in action.php we must use https://gist.github.com/awbush/1545535 for PHP < ?? (might find more info elsewhere)

If the file transit via PHP in action.php we must use https://gist.github.com/awbush/1545535 for PHP < ?? (might find more info elsewhere) <!-- github-comment-id:181939947 -->
Author
Owner

@mistic100 ok, so let's use readLargeFile instead of readfile :-) but we should always go through action.php and not give file direct url.

@mistic100 ok, so let's use readLargeFile instead of readfile :-) but we should always go through action.php and not give file direct url. <!-- github-comment-id:181951388 -->
Author
Owner

@mistic100 : don't there is any problem with readfile. here is a comment from readfile doc:
"readfile() will not present any memory issues, even when sending large files, on its own. If you encounter an out of memory error ensure that output buffering is off with ..."

@mistic100 : don't there is any problem with readfile. here is a comment from readfile doc: "readfile() will not present any memory issues, even when sending large files, on its own. If you encounter an out of memory error ensure that output buffering is off with ..." <!-- github-comment-id:181963606 -->
Author
Owner

I remember I used this trick for some misconfigured servers, something users can't configure themselves. I honestly don't remember what was the problem though.

I remember I used this trick for some misconfigured servers, something users can't configure themselves. I honestly don't remember what was the problem though. <!-- github-comment-id:181965201 -->
Author
Owner

I have encountered such problems (on Piwigo.com, for downloading 500MB zip files) but it was years ago and now I simply use a readfile.

Maybe we can wait for a bug report to implement readLargeFile instead of readfile. Maybe this problem never occurs with PHP 5.3+ (https://wordpress.org/about/stats/ says that 90%+ users are on PHP 5.3+)

I have encountered such problems (on Piwigo.com, for downloading 500MB zip files) but it was years ago and now I simply use a readfile. Maybe we can wait for a bug report to implement readLargeFile instead of readfile. Maybe this problem never occurs with PHP 5.3+ (https://wordpress.org/about/stats/ says that 90%+ users are on PHP 5.3+) <!-- github-comment-id:181967842 -->
Author
Owner
@modus75 can you tell me what you think of https://github.com/Piwigo/Piwigo/commit/a684afbdc33fc904734ee63152e3040dbdbaa1bd ? <!-- github-comment-id:218108813 -->
Author
Owner

It's ok for me ...

It's ok for me ... <!-- github-comment-id:218151325 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#399