Workaround that fixed this issue for me
I ran into what appears to be the same issue on my ProjectSend installation.
In my case, everything worked normally until a client uploaded some large/high-resolution JPG images. After that, certain pages started returning a 500 error.
What made it confusing was that the files themselves were fine. They could be downloaded without any problem, and PDFs also worked normally.
After some testing, I found that the 500 error was happening when ProjectSend tried to generate image thumbnails and read the image dimensions.
My PHP memory_limit is 128M. Instead of increasing it, I decided to disable thumbnail/dimension processing for images since I don't really need image previews in this portal.
This fixed the problem completely for me.
Files I changed
I had to make the change in three places:
- The client file list template (
template.php used by my_files)
manage-files.php
includes/forms/file_editor.php
The exact path of the client template may be different depending on the template being used.
1. Client file list / template.php
I removed/disabled the code that gets image dimensions:
if (file_is_image($file->full_path)) {
$dimensions = $file->getDimensions();
if (!empty($dimensions)) {
$title_content .= '<br><div class="file_meta"><small>' .
$dimensions['width'] . ' x ' .
$dimensions['height'] . ' px</small></div>';
}
}
I also stopped generating thumbnails for images.
Instead of calling make_thumbnail() for images, I only keep the normal Preview button for non-image files:
$preview_cell = '';
if ($file->expired == false) {
if (!$file->isImage() && $file->embeddable) {
$preview_cell =
'<button class="btn btn-warning btn-sm btn-wide get-preview" ' .
'data-url="' .
BASE_URI .
'process.php?do=get_preview&file_id=' .
$file->id .
'">' .
__('Preview', 'cftp_admin') .
'</button>';
}
}
2. manage-files.php
I did basically the same thing here.
I removed/disabled the image thumbnail block that calls:
make_thumbnail(
$file->full_path,
'proportional',
300,
300,
90
);
Then I changed the preview logic so that images don't generate thumbnails, while non-image files can still use the normal preview:
$preview_cell = '';
if (!$file->isImage() && $file->embeddable) {
$preview_cell =
'<button class="btn btn-warning btn-sm btn-wide get-preview" ' .
'data-url="' .
BASE_URI .
'process.php?do=get_preview&file_id=' .
$file->id .
'">' .
__('Preview', 'cftp_admin') .
'</button>';
}
I also disabled the image dimension lookup:
$dimensions = $file->getDimensions();
3. includes/forms/file_editor.php
This one was important because editing a large JPG would also result in a 500 error.
The file editor was generating a larger thumbnail with:
make_thumbnail(
$file->full_path,
'proportional',
400,
400,
90
);
It was also reading the image dimensions with:
I disabled both operations for images.
One thing worth mentioning: make sure you are editing the correct file.
On my installation, the file actually used by the editor is:
includes/forms/file_editor.php
Notice that it is file_editor.php with an underscore.
I initially edited a similarly named file with a hyphen instead of the underscore, which caused some confusion because my changes were not being applied to the actual form.
If you're not sure which file ProjectSend is loading, check the files-edit.php file. In my installation it loads the editor using:
include_once FORMS_DIR . DS . 'file_editor.php';
Result
After making these changes I tested:
- Manage Files
- Edit File
- View as Client
- Logging in directly through the client portal
- Large JPG images
- PDFs
- File downloads
Everything is working normally now.
The only functionality I intentionally gave up is automatic image thumbnails and the image dimension display. I don't need either of those for my use case.
The original images are still stored normally and clients can download them without any problem.
So at least in my case, the JPG files were not corrupted. The problem was triggered when ProjectSend tried to process large/high-resolution images to generate thumbnails and read their dimensions.
I kept my PHP memory_limit at 128M and chose this approach instead of increasing it.
Hopefully this helps someone else running into the same 500 error.