MyBB Community Forums

Full Version: File Upload Problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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

	// 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.
Same problem:

Works this?

Greetz,
I recommend upgrading to 1.6.6 though. It includes several security fixes and overall improvements. The update and uploading of fresh, new files may very well help.

You will need to update plugins because of a change in 1.6.5, but that can be done with pavemen's script.

Otherwise, do you have any attachment-related plugins installed?
Hellow, it is allready 1.6.6 that i have installed.
Yes i have Pro attachment installed as plugin but i have tryed also without any plugin.

Sad
It just said at the top of the post "MyBB 1.6.4, so I was curious.

Hopefully some team member can help. I know some stuff, but this isn't 100% in my range of knowledge. I just know that 1.6.6 works fine if it isn't upset with too many plugins Smile