MyBB Community Forums

Full Version: Can't upload images but other files
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hello!

I just installed MyBB 1.8 on my new webhost, so it's a fresh installation.

Everything else seems to check out fine, no errors in the "Tools & Maintenance"-area (all green) and posting and using the forum is fine.

But adding image-attachments to any post is impossible, I've tried both jpg and png. But pdf works and I suppose other file formats do too, that aren't images.

When I click the add attachment-button this is the screen I am greeted with: [attachment=32783]

When I reload that page I come to a page that says: "Can not upload file - Too large for php post_max_size directive. Please press the back button."

But I've checked the related php values and 50 MB is the max size of post and upload, so I find it hard to believe that is the actual problem.

When I check the uploads folder on the server it seems the file is uploaded with the extension .attach, so file uploading may actually work but something else is faltering?

I have no active plugins except for Tapatalk.

If you want to test for yourselves:

bitkoine.se
username: test
password: 123456

Help will be greatly appreciated, I am totally new on using MyBB and find it to be very usable and nice! Smile
Hmm... interesting. What webhost are you using, or are you using a self configured server?

I'm not sure if you're greeted with an actual PHP error or just a MyBB message when the page is reloaded. Blank pages generally indicate that PHP error displaying is disabled. If that's the case, you can enable MyBB to display errors temporarily by editing global.php and adding this to the top. It's not going to solve your problem, but might help disclose more information as to what's causing the issue. Toungue

error_reporting(E_ALL);
ini_set('display_errors', 1);

Also, although I imagine this probably isn't the issue, are you sure that the /uploads directory has write permissions set?
Hi!

Thanks for a rapid response!

I put the debug-code in the global.php-file but the response is still empty when trying to post images.

When posting a very small jpg it seems it got through when I pressed command+R and resending the form-data. Which is strange.

I am using http://fsdata.se as my webhost.
According to this: https://twitter.com/fsdata/status/501484792291266561 you should turn off the mod_security module in .htaccess file. Adding this code to that file should do it:
<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>
If not, ask your hosting for more info.
Big thanks Destroy666!

But it doesn't work, I've had the myBB htaccess-file turned on all of the time. I even installed it on another domain at the same host and it didn't work even before I did any customizations (the included htaccess turns that module off).

The thing that bugs me is that my wordpress-installation kan upload the pictures with it's ajax uploader without any problem.

I will contact the hosts support to see if they have any ideas on what to do. Thank you again!

Another interesting thing I found out is that all the images I've tried to upload are there, in the "uploads/201410" folder, so they are actually uploaded but then something gets stuck!

Is there maybe a way forward anyway?
(10-16-2014, 06:33 PM)silverkors Wrote: [ -> ]But it doesn't work, I've had the myBB htaccess-file turned on all of the time. I even installed it on another domain at the same host and it didn't work even before I did any customizations (the included htaccess turns that module off).

What do you mean by 'turned on'? Are you sure you're using the default MyBB .htaccess file (no extension, dot at the beginning)? Asking because as I can see you still have the .txt file: http://bitkoine.se/htaccess.txt which does basically nothing.

If yes, please provide a temporary account with ACP access in PM.
I renamed the htaccess back to a txt-file again when I was about to add the options you suggested to the htaccess-file and discovered that the htaccess (provided with the installation) already had those options disabled.

I have put the .htaccess back once more and I will send you ACP details.

To be really clear about what I have as an .htaccess right, it is this:

Options -MultiViews +FollowSymlinks -Indexes

#
# If mod_security is enabled, attempt to disable it.
# - Note, this will work on the majority of hosts but on
#   MediaTemple, it is known to cause random Internal Server
#   errors. For MediaTemple, please remove the block below
#
<IfModule mod_security.c>
# Turn off mod_security filtering.
SecFilterEngine Off

# The below probably isn't needed, but better safe than sorry.
SecFilterScanPOST Off
</IfModule>



#
# MyBB "search engine friendly" URL rewrites
# - Note, for these to work with MyBB please make sure you have
#   the setting enabled in the Admin CP and you have this file
#   named .htaccess
#
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^forum-([0-9]+)\.html$ forumdisplay.php?fid=$1 [L,QSA]
RewriteRule ^forum-([0-9]+)-page-([0-9]+)\.html$ forumdisplay.php?fid=$1&page=$2 [L,QSA]

RewriteRule ^thread-([0-9]+)\.html$ showthread.php?tid=$1 [L,QSA]
RewriteRule ^thread-([0-9]+)-page-([0-9]+)\.html$ showthread.php?tid=$1&page=$2 [L,QSA]
RewriteRule ^thread-([0-9]+)-lastpost\.html$ showthread.php?tid=$1&action=lastpost [L,QSA]
RewriteRule ^thread-([0-9]+)-nextnewest\.html$ showthread.php?tid=$1&action=nextnewest [L,QSA]
RewriteRule ^thread-([0-9]+)-nextoldest\.html$ showthread.php?tid=$1&action=nextoldest [L,QSA]
RewriteRule ^thread-([0-9]+)-newpost\.html$ showthread.php?tid=$1&action=newpost [L,QSA]
RewriteRule ^thread-([0-9]+)-post-([0-9]+)\.html$ showthread.php?tid=$1&pid=$2 [L,QSA]

RewriteRule ^post-([0-9]+)\.html$ showthread.php?pid=$1 [L,QSA]

RewriteRule ^announcement-([0-9]+)\.html$ announcements.php?aid=$1 [L,QSA]

RewriteRule ^user-([0-9]+)\.html$ member.php?action=profile&uid=$1 [L,QSA]

RewriteRule ^calendar-([0-9]+)\.html$ calendar.php?calendar=$1 [L,QSA]
RewriteRule ^calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)\.html$ calendar.php?calendar=$1&year=$2&month=$3 [L,QSA]
RewriteRule ^calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)-day-([0-9]+)\.html$ calendar.php?action=dayview&calendar=$1&year=$2&month=$3&day=$4 [L,QSA]
RewriteRule ^calendar-([0-9]+)-week-(n?[0-9]+)\.html$ calendar.php?action=weekview&calendar=$1&week=$2 [L,QSA]

RewriteRule ^event-([0-9]+)\.html$ calendar.php?action=event&eid=$1 [L,QSA]

<IfModule mod_env.c>
SetEnv SEO_SUPPORT 1
</IfModule>
</IfModule>

#
# If Apache is compiled with built in mod_deflade/GZIP support
# then GZIP Javascript, CSS, HTML and XML so they're sent to
# the client faster.
#
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE application/javascript text/css text/html text/xml
</IfModule>
Please put long code between [code] tags (edited your post).

Anyways, so far I can see you got other problems as well:
- ACP -> Tools & Maintenance -> Recount & Rebuild -> Rebuild Attachment Thumbnails = blank page
- ACP -> Tools & Maintenance -> Optimise Database -> Select All = 403 error

I'd also like to see the most recent content of your error.log file.
Thanks for editing my post with edit-blocks.

I can't access the error.log by myself so I have sent and e-mail to the hosts support, but they haven't responded yet.

So I started playing the "commenting out code to find the problem"-game.

If I comment out one line in "functions_image.php" the attachments-process works but I get no thumbnail.

It works if I comment out this line in the function "check_thumbnail_memory":

@ini_set("memory_limit", $memory_limit);

It is at the very end nested in the if statement that checks if the thumbnail_memory is larger than free_memory.

But I don't know enough PHP to have any idea why this is.

---

Update: I did an ugly ImageMagick-hack so right now thumbnail-generation works (and also the regeneration button in the Tools-section). But If would rather use the real MyBB way of doing it.

This is what I use right now:

function generate_thumbnail($file, $path, $filename, $maxheight, $maxwidth)
{
	$thumb = array();

	$imgdesc = getimagesize($file);
	$imgtype = $imgdesc[2];

	$handle = fopen($file, 'rb');
	$im = new Imagick();
	$im->readImageFile($handle);
	fclose($handle);
	if($imgtype == 3)
	{
		$im->setImageFormat("png24");
	}
	elseif($imgtype == 2)
	{
		$im->setImageFormat("jpeg");
	}
	elseif($imgtype == 1)
	{
		$im->setImageFormat("gif");
	}
	$geo=$im->getImageGeometry();
	$width=$geo['width'];
	$height=$geo['height'];
	if($width > $height)
	{
		$scale = ($width > $maxwidth) ? $maxwidth/$width : 1;
	}
	else
	{
		$scale = ($height > $maxheight) ? $maxheight/$height : 1;
	}
	$newWidth = $scale*$width;
	$newHeight = $scale*$height;
	$im->setImageCompressionQuality(85);
	$im->resizeImage($newWidth,$newHeight,Imagick::FILTER_LANCZOS,1.1);
	$im->writeImage($path."/".$filename);
	$im->clear();
	$im->destroy();
	
	@my_chmod($path."/".$filename, '0644');
	$thumb['code'] = 1;
	$thumb['filename'] = $filename;
	return $thumb;	
}
(10-18-2014, 07:26 AM)silverkors Wrote: [ -> ]It works if I comment out this line in the function "check_thumbnail_memory":


@ini_set("memory_limit", $memory_limit);

It is at the very end nested in the if statement that checks if the thumbnail_memory is larger than free_memory.

It may be connected with this then: http://stackoverflow.com/questions/50619...ing-at-all
Pages: 1 2