Chmod MODx MaxiGallery fix

MaxiGallery is a customizable image gallery for the PHP application framework/CMS MODx. I have been testing it out locally on a windows based PC running Apache, and came across an error when trying to upload files as per the Picture and Thumbnails walkthrough.

« MODx Parse Error »

MODx encountered the following error while attempting to parse the requested resource:

« PHP Parse Error »
PHP error debug
Error: chmod() [function.chmod]: No such file or directory
Error type/ Nr.: Warning – 2
File: assetssnippetsmaxigallerymaxigallery.php
Line:372
Line 372 source: chmod($mg->path_to_gal.$name,0666);

The fix thanks to doze on the modxcms forums:

Try changing lines 371 – 378 in maxigallery.php from:
Code:

move_uploaded_file( $_FILES['file'.$i]['tmp_name'] , $mg->path_to_gal.$name );
chmod($mg->path_to_gal.$name,0666);

$handleMessage = $mg->handleFile($name, $modx->db->getRecordCount($rsx));
if ($handleMessage != “”) {
$manageOuterTplData['messages'] .= $handleMessage;
$upload_error = true;
}

to:
Code:

if(move_uploaded_file( $_FILES['file'.$i]['tmp_name'] , $mg->path_to_gal.$name )) {
chmod($mg->path_to_gal.$name,0666);

$handleMessage = $mg->handleFile($name, $modx->db->getRecordCount($rsx));
if ($handleMessage != “”) {
$manageOuterTplData['messages'] .= $handleMessage;
$upload_error = true;
}
}

This worked for me without needing to do the other changes that he mentioned in the post, but if it doesn’t work for you, try checking out the rest of his comments.

8 Comments

Leave a comment

Your email address will not be published. Required fields are marked.