Skip to content

Instantly share code, notes, and snippets.

@nicoknoll
Last active August 29, 2015 14:04
Show Gist options
  • Save nicoknoll/4f2aec3972ca0f933b6e to your computer and use it in GitHub Desktop.
Save nicoknoll/4f2aec3972ca0f933b6e to your computer and use it in GitHub Desktop.

File related problems

This guide will help you to solve the most common problems related to files.

File permissions

First of all (even if you don't have any problems at the moment) you should make sure that your current file permissions are right set:

/site/assets/ 755 (recursively)
...

While installing ProcessWire you have the chance to control which file permissions should be given to files and folders created by ProcessWire. If you want to change them afterwards you can find them in your /site/config.php or use the ProcessWireConfig module to change/see them:

// default settings
$config->chmodDir = '0755';
$config->chmodFile = '0644';

Error log won't update

If you get the note that there was an error which got logged in the error log ("Unable to complete this request due to an error. Error has been logged.") but the error log isn't updated this is probably due to wrong file permissions (just scroll a bit upwards).

Download modules within ProcessWire is not possible

If you want to use ProcessWire's build-in functionality to install new modules directly from the ProcessWire backend you have to make sure your provider has set "allow_url_fopen = 1". (If your not sure try to contact your hoster directly and ask him or use PHP's phpinfo() function).

Or if you have access to your php.ini you can manually add this setting.

UPDATE: This problem shouldn't occur anymore in up-to-date ProcessWire installations (2.5+) as there is a curl-fallback function now.

Upload stuck at 100%

If this error occurs to you there are various reasons this could come from. First step should be to take a look into your browser's console and check if there is any error.

Here are two solutions that might work:

  1. Take a look at your mod_security settings. Sometimes they are wrong configured and prevent the page from using Ajax Upload.

  2. Disable Ajax upload. You can do this by editing wire/modules/Inputfield/InputfieldFile/InputfieldFile.js (it's normally not recommended to edit files in /wire/ but in this case you can do it just for debugging. Note that this file be overwritten when you update ProcessWire).

Somewhere in this .js file you should find a part looking like this:

if (window.File && window.FileList && window.FileReader && $("#PageIDIndicator").size() > 0) {  
		InitHTML5();  
	} else {
		InitOldSchool();
	}

Now just replace InitHTML5() with InitOldSchool() and try if uploads are working now or anything has changed. If not you can get additional support at the forum.

"Invalid file extension, please use one of:"

If this error occur's there are two possible reasons:

  1. You haven't configured your file/image-field completely. To solve this just go to "setup > fields > yourfield", click edit and just hit save afterwards.
  2. You haven't added the file extension to the allowed file extensions of your field. To solve this go back to that field again, click on it's "details" tab and note the file extensions. Make sure that the file type you are uploading is in the list of allowed extensions. Add more extensions as needed and save the field.

Can't upload .exe/.php/.cgi/...

To improve the security of your ProcessWire installation there is a list of "bad" file extensions which can't be uploaded even if you added their type to the "allowed file extensions" of your field. These list is defined in your /site/config.php:

$config->uploadBadExtensions = 'php php3 phtml exe cfm shtml asp pl cgi sh vbs jsp';

If you're sure you want to allow your users to upload those filetypes you can change this setting directly in your /site/config.php or you can use the ProcessWireConfig module.

Note: It's probably better not to change it and tell your users to wrap those filetypes into zips and upload the .zip file.

Can't upload huge files / huge file upload stucks

If you want to upload huge files into your ProcessWire installation make sure your post_max_size and upload_max_filesize are bigger than your file. You can check this by using PHP'sphpinfo() function or by using the ProcessDiagnostics module.

If you notice that it is smaller than your file you can try to increase it by adding the following lines to your htaccess file. Note: In most cases this won't help.

<IfModule mod_php5.c>
php_value post_max_size 240M
php_value upload_max_filesize 200M
</IfModule>

If this is not working you can either contact your hoster and ask for increasing your post_max_size and upload_max_filesize or using a little work around:

You can create a /tmp/ folder in your ProcessWire installation's root directory and upload all your huge files into it via FTP. Afterwards you create a file in the same directory as your /tmp/ folder (e.g. "uploadhelper.php"). This file should look similar as this:

<?php
include 'index.php';

$filepage = $pages->get('the-page-you-want-to-add-the-files-to'); // you have to change this line
$filepage->of(false);
$filepage->fieldname->add($config->paths->root.'tmp/hugefile.zip'); // you have to change this line for every file or use a for each loop
$filepage->save();
?>

This code tells ProcessWire to add the huge file to a given page and copy it to the assets folder. Afterwards you can delete the file from the /tmp/ folder. Feel free to adjust it to your needs. I marked all the parts you have to adjust in bold.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment