Jump to content

$MaxFileSize client upload


Recommended Posts

First off this is the issue.
I need my clients to upload a image when they buy a product.
This image will be then printed at 32"x44" so i need a high resolution image.

So don't tell me i don't need a BIG IMAGE!

The issue I'm having is that when i try to upload a large image from the client side
I get the error (image is too large (xxxxKB). Maximum allowed: 131.072KB)

My php settings are set for a maximum of 38MB upload and post size.
I have already modified the $MaxFileSize in the
admin\tabs\adminatachments.php to allow me to upload large images from the backoffice.

Now I just need to find what php file contains the settings for the client side upload.

and yes I have used the search button blaw blaw blaw keep on flaming your not helping...

Thank you,

Link to comment
Share on other sites

I managed to get this working... somewhat.
Under images.inc.php

function    checkImage($file, $maxFileSize)
{
   if ($file['size'] > 32000000)//$maxFileSize)
       return Tools::displayError('image is too large').' ('.($file['size'] / 1000).Tools::displayError('KB').'). '.Tools::displayError('Maximum allowed:').' '.($maxFileSize / 1000).Tools::displayError('KB');
   if (!isPicture($file))
       return Tools::displayError('image format not recognized, allowed formats are: .gif, .jpg, .png');
   if ($file['error'])
       return Tools::displayError('error while uploading image; change your server\'s settings');
   return false;
}


I commented out the $maxFileSize and replaced it with my own, and it seemed to work.

Now the error I'm receiving is
Warning: exec() [function.exec]: Unable to fork [file -b --mime-type "C:\Inetpub\temp\php3FC.tmp"]
I'm sure this is a php/windows permission error I'll figure it out and post more.

Link to comment
Share on other sites

I think i got everything working.
But I have one question.

After uploading an image I get an error
Warning: exec() [function.exec]: Unable to fork [file -b —mime-type “C:\Inetpub\temp\php3FC.tmp”]

What does the following code do? This code is located under images.inc.php line 89
Everything else works till this point.

$mime_type = trim(exec('file -b --mime-type '.escapeshellarg($file['tmp_name'])));



Additionally
when a file attachment is uploaded by a client how is it attached to the product they purchased.
So far I see no reference, do I have have add that myself?

Link to comment
Share on other sites

thank you RapidTime,

But I think i figured out what it was.
It seems that the image was being uploaded to the \uploads\
and it was given a md5 file name.
The file is then re-sized and placed somewhere else.
But the $file['tmp_name'] was looking for the file in the \img\tmp\ directory
so I added some code at the bottom of the function that copied the files to the expected location

copy(_PS_PROD_PIC_DIR_.$fileName,$file['tmp_name']);
chmod($file['tmp_name'], 0755);



But now there are some permission errors as posted above.
I've added the chmod to edit the permissions.
This still caused an issue so I commented out the line since I can't tell what the hell that line is doing anyways.

I guess my next challenge is to associate the uploaded file with the current product and then add it to the cart.

Link to comment
Share on other sites

  • 4 months later...
well i guess my stuff was just wrong to begin with.

I changed the line to the following and it worked

$mime_type = trim(@exec('file -bi '.escapeshellarg($file['tmp_name'])));


I changed as same with you mentioned. hit error msg :
Parse error: parse error, unexpected T_STRING in E:\wwwusr\vhosts\easternprinters.com\httpdocs\store\images.inc.php on line 80

Any idea?
Link to comment
Share on other sites

Greetings a_sun.

It's been a while since I worked on this code. I can't really remember what I did to get everything working.
But I do know that it now works on my site.
I'll post my images.inc.php file perhaps you might find what you need from it.
I'll try and go over it again and see if I can recall what I changed.

http://www.customscrolls.com/images.inc.php.txt

Link to comment
Share on other sites

It's starting to come back to me.
I remember the issue being with function isPicture
depending on the version of php their are several different commands
to get the file type.

You'll have to do a search on the web for your php version
and find a method of returning back the file type ($mime_type)

The function already contains a few methods but they might have changed
if your php version is newer.

You can see what I use in my previous post.

Link to comment
Share on other sites

Greetings a_sun.

It's been a while since I worked on this code. I can't really remember what I did to get everything working.
But I do know that it now works on my site.
I'll post my images.inc.php file perhaps you might find what you need from it.
I'll try and go over it again and see if I can recall what I changed.

http://www.customscrolls.com/images.inc.php.txt


Hi stevel:
After replace with your images.inc.php, I hit another error...

Warning: unlink(E:\wwwusr\vhosts\easternprinters.com\httpdocs\store/upload/921cb63704e35d288742e2e70a069517) [function.unlink]: Permission denied in E:\wwwusr\vhosts\easternprinters.com\httpdocs\store\classes\Cart.php on line 972

Warning: unlink(E:\wwwusr\vhosts\easternprinters.com\httpdocs\store/upload/921cb63704e35d288742e2e70a069517_small) [function.unlink]: Permission denied in E:\wwwusr\vhosts\easternprinters.com\httpdocs\store\classes\Cart.php on line 973

I have checked my ttpdocs\store/upload & Cart.php Permission been set to "Read & Write"
Any idea?

Many Thanks.
Link to comment
Share on other sites

×
×
  • Create New...