Could not move uploaded file to destination Drupal 8 - file-upload

I have a trouble gatting drupal to upload files (images, configuration, I guess anything).
The error message is:
The file could not be saved because the upload did not complete.
File upload error. Could not move uploaded file.
When I go to log it says:
Upload error. Could not move uploaded file multimedia.svg to destination public://2017-03/multimedia.svg.
I already read about permissions and here they are:
sites/default/files - 770
sites/default/files/2017-03 - 770
/tmp - 1777
However I'm able to upload & install themes and modules without any ploblems at all.
So what could it be? And how do I fix this?

switch php mode from "Apache module (mod_php)" to "Fast CGI (mod_fcgid)"
core\includes\file.inc
function file_prepare_directory()
should return true
see this patch
or just temporarily put
return true;
instead of
return $writable;
in the function

Related

Laravel 403 error when displaying images from storage folder

I am unable to access files saved to the storage folder. I'm able to upload, files, save files. If I run for example the size method it gets the file size of the uploaded image but when it comes to displaying the file, I get a 403 error. I used the laravel artisan command to create the symlink, I've tried manually creating the symlink. I've checked to verify that follow symlinks is in my apache config, I can cd into it from shell the permissions are 777 (I had it 755 but in trying to figure it what is wrong I changed it to 777) ownership of the symlink and files inside are all the same user and group as every other file in the public directory.
I'm super tired so maybe I'm just missing something obvious, but I can't for the life of me figure out what is wrong. The file clearly exists, its visibility set to "public". Is there any reason why I'd be able to write the directory but not display images saved there?
Edit 1:
web
app
bootstrap
config
database
error
node_modules
public
resources
routes
stats
storage
temp
vendor
Is the basic structure, with a symlink inside public pointing at storage/app/public
the filesystems for my storage folder config is:
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
I haven't really edited anything from the basic laravel install at this point. I did read someone else having a similar problem, said their issue is they weren't allow to access direcotires outside of their document root. So they just had all uploads go to their public folder instead of using the storage folder. I do have my document root set to my public folder. Could that be a problem? (I can edit my apache file if needed)
Ok - got some sleep and this morning looked over everything and realized that when logged in as the site owner, everything looks fine, however when logged in as root it shows the link as broken. Basically artisan creates an absolute link, which /storage/app/public is fine as the site owner because its a jailkitted account whose "root" directory is the web folder. However it was actually creating a symlink to the system root, of which the normally account doesn't have access to so it was returning a 403
Basically I just made the as a relative link instead of an absolute one by removing the broken symlink laravel created and while in the public directory entering:
ln -s ../storage/app/public storage
I had the same issue, after a lot of debugging i managed to identify the actual problem that caused 403 error.
Solution is simple, in
Config/Filesystem.php
where you define your public_path and storage path, you must have same/identical public_path name and storage_path end directory name.
Example:
Incorrect:
public_path('brands') => storage_path('storage/app/public/brandimages');
This will generate 403 error, "since public_path('brands')" is not same as "storage_path('../../../brandsimage')".
Correct:
public_path('brands') => storage_path('storage/app/public/brands');
Now the public_path('brands') and "storage_path('../../../brands')" are same, therefore, correct symlinks will generated,thus solving 403 error.
Generate symlinks with following artisan command
php artisan storage:link
if relative links need to be generated, than use following command
php artisan storage:link --relative
My hosting is a clud server, and my site path is /httpdocs
The solution worked for me, was:
from folder /httpdocs/public, execute ln -s ../storage/app/public storage
then everything works fine.

Drupal 8 File Upload error: Could not move uploaded File

I have created a new content type, and all of a sudden I can not upload any images to my site. It is a local server so disk space is not an issue.
The error is
The file could not be saved because the upload did not complete.
File upload error. Could not move uploaded file.
This value should not be null."
It is drupal 8.1.8
I have changed the temp directory to a place that www-data has full read and write permissions, as well as changing the files folder to 777, none of which seem to fix the issue.
There isn't even any apache errors that are being thrown, the only error is in drupal logs and on the page
error screen
on drupal root directory try
sudo chcon -R -t httpd_sys_rw_content_t sites/default/files
See the folder premissions here: https://drupal.stackexchange.com/questions/373/what-are-the-recommended-directory-permissions. This is a common folder permissions issue.
I fixed the problem on (Laragon, Drupal 9 & Windows 10) by changing the PHP from NTS to Thread Safe.

Moving Smarty website to new server

I'm moving a website to a new domain and server and I'm running into some problems. This website works with Smarty, and I've never used it before. I think I got a very basic problem, but I can't find the answer online.
I've moved all the FTP files to the new server
I've copied the database
I've edited the config file with the new database information
Now only EVERY page (even a blank test.php file with a simple echo) I get "failed to open stream" errors.
Warning: rename(/home/*websitename*/domains/*websitename*.com/public_html//skins/default/compiled/65e3d4d7349f9687ce73f56b61992749304409a2.file.index.tpl.php) [function.rename]: failed to open stream: Permission denied in /home/*websitename*/domains/*websitename*.com/public_html/external/smarty/sysplugins/smarty_internal_write_file.php on line 48
Warning: rename(/tmp/wrtPBIHNP,/home/*websitename*/domains/*websitename*.com/public_html//skins/default/compiled/65e3d4d7349f9687ce73f56b61992749304409a2.file.index.tpl.php) [function.rename]: Permission denied in /home/*websitename*/domains/*websitename*.com/public_html/external/smarty/sysplugins/smarty_internal_write_file.php on line 48
Warning: chmod() [function.chmod]: No such file or directory in /home/*websitename*/domains/*websitename*.com/public_html/external/smarty/sysplugins/smarty_internal_write_file.php on line 50
Warning: include(/home/*websitename*/domains/*websitename*.com/public_html//skins/default/compiled/65e3d4d7349f9687ce73f56b61992749304409a2.file.index.tpl.php) [function.include]: failed to open stream: No such file or directory in /home/*websitename*/domains/*websitename*.com/public_html/external/smarty/sysplugins/smarty_internal_template.php on line 432
Warning: include() [function.include]: Failed opening '/home/*websitename*/domains/*websitename*.com/public_html//skins/default/compiled/65e3d4d7349f9687ce73f56b61992749304409a2.file.index.tpl.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/*websitename*/domains/*websitename*.com/public_html/external/smarty/sysplugins/smarty_internal_template.php on line 432
It looks like a problem with premissions, but I've made EVERY file on the FTP premission 777 (to test) and this does not solve it.
There are two backslashes /public_html//skins/ which is weird.
The code is exactly the same on the "old" server, besides the config file. Only thing new is the domain name.
What am I doing wrong?
You should set for directory compiled permissions 755 or 777.
You should probably also remove all compiled and cached files (if you use cache) because it may also cause problems

reputation module installation in phpbb3

Hi i am trying to install phpbb-reputation system i followed the xml file for installation but while executing install_reputation.php i am getting this error ERROR: Could not open the file ./styles/afterburnerafterburner_config.html for reading.There are many errors in the same fashin. where i gues it is not going inside afterburner/template folder where .html file exists. where should i check this?
More error samples:
Refreshing the proFormell template
ERROR: Could not open the file ./styles/proFormellcaptcha_recaptcha.html for reading.
Sounds like it's a permissions issue; if hosting on a LAMP server, just run chmod 755 * -R in the website root directory. Alternatively you could also change file permissions using an FTP client

Can't upload tmp file / file uploads won't work

I just switched to a dedicated server. All of the sudden I can't upload files. My best guess because the tmp file isn't getting uploaded? Each time I try to do move_uploaded_file('tmp','new_image'); I get permission denied and failed to open stream.
I changed nothing in the script; but the absolute path obviously. Also, all file permissions are set to 705. I think it's something to do with the php.ini where the tmp files aren't working... I no longer have the default php.ini from shared hosting. Any ideas what might be causing this? Thank you
Here's my php.ini
extension_dir = ./
upload_tmp_dir = ./tmp
-- more but not relevant
`Warning: move_uploaded_file(users/126/question_images/question mark.jpeg): failed to open` stream:
Here's the permission denied error
Permission denied in ---.php on line 115 Warning: move_uploaded_file():
Here's the other error
Unable to move '/tmp/phpVrkytD' to '---.jpeg' in .---.php on line 115
Here's the part of the script to upload the image
$long_image_loc = 'absolute_path/'.$image_name;
if(move_uploaded_file($image_tmp_name, $long_image_loc) === true) {
return true;
}
This worked worked perfect on shared hosting. It's a really straight forward image upload script.