Uploading through File Manager with 123-reg

Permalink 3 users found helpful
I recently created a concrete5 site on a 123-reg server.

Everything works fine, and you don't get any issues until you attempt to upload files through the file manager.

123-reg will automatically upload files with a 644 file permission, and concrete needs at least 755 to be able to read the files that you have uploaded, so all you will get is a little box with the red cross.

To fix this you need to edit two files.

/concrete/helpers/concrete/file.php

change the following code, found on line 94-107 (Concrete 5.4.2.2) from:
if ($createDirectories) { 
               if (!is_dir($base . '/' . $d1)) { 
                  @mkdir($base . '/' . $d1, 0777, TRUE); 
                  @touch($base . '/' . $d1 . '/index.html');
               } 
               if (!is_dir($base . '/' . $d1 . '/' . $d2)) { 
                  @mkdir($base . '/' . $d1 . '/' . $d2, 0777, TRUE); 
                  @touch($base . '/' . $d1 . '/' . $d2 . '/index.html');
               } 
               if (!is_dir($base . '/' . $d1 . '/' . $d2 . '/' . $d3)) { 
                  @mkdir($base . '/' . $d1 . '/' . $d2 . '/' . $d3, 0777, TRUE); 
                  @touch($base . '/' . $d1 . '/' . $d2 . '/' . $d3 . '/index.html');
               } 
            }


to:

if ($createDirectories) { 
               if (!is_dir($base . '/' . $d1)) { 
                  @mkdir($base . '/' . $d1, 0777, TRUE); 
                  @chmod($base . '/' . $d1, 0777); 
                  @touch($base . '/' . $d1 . '/index.html');
               } 
               if (!is_dir($base . '/' . $d1 . '/' . $d2)) { 
                  @mkdir($base . '/' . $d1 . '/' . $d2, 0777, TRUE); 
                  @chmod($base . '/' . $d1 . '/' . $d2, 0777); 
                  @touch($base . '/' . $d1 . '/' . $d2 . '/index.html');
               } 
               if (!is_dir($base . '/' . $d1 . '/' . $d2 . '/' . $d3)) { 
                  @mkdir($base . '/' . $d1 . '/' . $d2 . '/' . $d3, 0777, TRUE); 
                  @chmod($base . '/' . $d1 . '/' . $d2 . '/' . $d3, 0777); 
                  @touch($base . '/' . $d1 . '/' . $d2 . '/' . $d3 . '/index.html');


And the other file you will need to change is:

/concrete/libraries/file/importer.php

change the following code, found on line 94 (Concrete 5.4.2.2) from:

return @copy($pointer, $path);


to:

$done = @copy($pointer, $path);
@chmod($path, 0777);
return $done;


This will now create the file structure with a 777 permission, and all the files uploaded will have the correct permissions too.

Hope this helps anyone who has had the same problems!

adz
 
pvernaglia replied on at Permalink Reply
pvernaglia
Copy those files to

/libraries/file/importer.php
/helpers/concrete/file.php

You don't want to be editing things under the concrete directory, they can get overwritten when you do upgrades.
adz replied on at Permalink Reply
adz
Yeah sorry I forgot to mention that!
nickodalton replied on at Permalink Reply
nickodalton
I get this error when adding the helper file:

"Cannot redeclare class ConcreteFileHelper"

any ideas?
thanks
adz replied on at Permalink Reply
adz
I've noticed that sometimes, you cannot create some of the helper files, I've noticed this with File and Pagination. So You will need to either modify the original directly, or just rename it so that it cannot be found - I normally create a new file and rename the original to _FileName.php
simonlonsdale replied on at Permalink Reply
I will say that this has kept me sane after a year of madness. I have to add though with updating to 5.5.1 I had to hide the files in the update directory to get this to work but work it does. Thanks
olay replied on at Permalink Reply
olay
Thanks everyone – this has *almost* solved a problem I am dealing with.

However my file permissions also extends to the cache folder… so for any image which creates a cached version of itself (this particularly occurs when you are using the image helper getThumbnail function) then new files in the cache folder are still created using the incorrect permissions, and thus cannot be seen on the website.

Is there anyway of making further changes to the file/importer files to solve this?

Many thanks!
gl650dude replied on at Permalink Reply
gl650dude
Hi

I'm new to Concrete5 and had this image issue as soon as I installed the software. I have a 123.reg hosting account (legacy Supanames).

The fix worked perfectly and files can be uploaded except the thumbnails are stil not showing. The images do appear on the created page however.

Thanks for your help.