2011-11-30, 05:29 PM
MyBB 1.6.4
Can't give a link, it's in the internal network.
When trying to upload a file I get error: The file upload failed. Please choose a valid file and try again. Error details: The attachment could not be found on the server.
I've changed this piece of code in functions_upload.php
to
Now the error looks like this: The file upload failed. Please choose a valid file and try again. Error details: The attachment could not be found on the server. ./uploads/201111/post_4_1322673716_cfc9aec2a427d4b3e2e1af04b04e6d75.attach
But when looking in the server I've found the post_4_1322673716_cfc9aec2a427d4b3e2e1af04b04e6d75.attach file not in the ./uploads/201111/ directory but in the ./uploads/ directory.
I think this is a bug.
P.S.
All permissions are set correctly.
I think this will correct the bug:
Change this
to
What do you think, experienced PHP developers?
P.S.2
The permissions for monthly folders were not correct, but the checking script in the administration panel was not reporting about that.
Can't give a link, it's in the internal network.
When trying to upload a file I get error: The file upload failed. Please choose a valid file and try again. Error details: The attachment could not be found on the server.
I've changed this piece of code in functions_upload.php
// Lets just double check that it exists
if(!file_exists($mybb->settings['uploadspath']."/".$filename))
{
$ret['error'] = $lang->error_uploadfailed.$lang->error_uploadfailed_detail.$lang->error_uploadfailed_lost;
return $ret;
}
to
// Lets just double check that it exists
if(!file_exists($mybb->settings['uploadspath']."/".$filename))
{
$ret['error'] = $lang->error_uploadfailed.$lang->error_uploadfailed_detail.$lang->error_uploadfailed_lost.
' '.$mybb->settings['uploadspath']."/".$filename;
return $ret;
}
Now the error looks like this: The file upload failed. Please choose a valid file and try again. Error details: The attachment could not be found on the server. ./uploads/201111/post_4_1322673716_cfc9aec2a427d4b3e2e1af04b04e6d75.attach
But when looking in the server I've found the post_4_1322673716_cfc9aec2a427d4b3e2e1af04b04e6d75.attach file not in the ./uploads/201111/ directory but in the ./uploads/ directory.
I think this is a bug.
P.S.
All permissions are set correctly.
I think this will correct the bug:
Change this
// Failed to create the attachment in the monthly directory, just throw it in the main directory
if($file['error'] && $month_dir)
{
$file = upload_file($attachment, $mybb->settings['uploadspath'].'/', $filename);
}
if($month_dir)
{
$filename = $month_dir."/".$filename;
}
to
// Failed to create the attachment in the monthly directory, just throw it in the main directory
if($file['error'] && $month_dir)
{
$file = upload_file($attachment, $mybb->settings['uploadspath'].'/', $filename);
$month_dir = '';
}
if($month_dir)
{
$filename = $month_dir."/".$filename;
}
What do you think, experienced PHP developers?
P.S.2
The permissions for monthly folders were not correct, but the checking script in the administration panel was not reporting about that.