Page 1 of 3

[RELEASED] - 0.7.9 File Upload

Posted: Wed Oct 15, 2008 7:16 am
by randomfactor
This contribution supports customer uploaded image files.  It is appropriate for catalog items that require a customized photo file supplied by the customer (e.g. T-shirts, coffee cups, embroidered goods).

There are two distinct parts of the contribution -- the first enhances OpenCart with an extensible product option feature.  The second is the file upload contribution which extends the product option to support uploading files.  The product option enhancement is included as a zip file within the file upload contribution zip.

Features
  • Upload an image file for a product
  • Progress bar during upload
  • Preview a thumbnail of the uploaded image
  • Supports gif, jpeg, bmp, and png formats
  • Installation and setup instructions (and you'll need them!)
Requirements
  • OpenCart version 0.7.9
  • PHP v5.2.4 (or better)
  • Perl v5.8 (or better)
  • enabled cgi-bin scripts
Demo site: http://www.digispray.com/demo/store/

File Upload Contrib: http://www.opencart.com/contribution/in ... tion_id/73

Re: [RELEASED] - 0.7.9 File Upload

Posted: Wed Oct 15, 2008 7:40 am
by Qphoria
awesome! I love how you got it in a lightbox style. Very modern :)

Bug when using url alias

Posted: Wed Oct 15, 2008 2:38 pm
by randomfactor
I've noticed that there is a bug when Use URL Alias: is set to Yes.  The progress bar and the thumbnails do not work under that condition.  I'll put out a new copy when I've fixed the problem.

Re: [RELEASED] - 0.7.9 File Upload

Posted: Thu Oct 16, 2008 2:38 am
by robgtheengineer
When I try to upload an image it either just sits there or gives me a bunch of junk, what do you think? http://123picturethis.com/index.php?con ... duct_id=21

Re: [RELEASED] - 0.7.9 File Upload

Posted: Thu Oct 16, 2008 3:17 am
by Qphoria
robgtheengineer wrote: When I try to upload an image it either just sits there or gives me a bunch of junk, what do you think? http://123picturethis.com/index.php?con ... duct_id=21
Try the contrib using the new 0.7.9 RC2 version of opencart from the News & Announcements area. It fixes a problem with displaying html that might fix this.

Re: [RELEASED] - 0.7.9 File Upload

Posted: Thu Oct 16, 2008 6:09 am
by robgtheengineer
now when i try to add to cart i get the following error:

Warning: Invalid argument supplied for foreach() in /home/capemb/public_html/library/cart/product_option.php on line 251

Warning: Cannot modify header information - headers already sent by (output started at /home/capemb/public_html/library/cart/product_option.php:251) in /home/capemb/public_html/library/environment/response.php on line 23

Re: [RELEASED] - 0.7.9 File Upload

Posted: Thu Oct 16, 2008 9:34 am
by randomfactor
robgtheengineer wrote: now when i try to add to cart i get the following error:

Warning: Invalid argument supplied for foreach() in /home/capemb/public_html/library/cart/product_option.php on line 251

Warning: Cannot modify header information - headers already sent by (output started at /home/capemb/public_html/library/cart/product_option.php:251) in /home/capemb/public_html/library/environment/response.php on line 23
What is your environment?  OS?  PHP version?  Perl version?

Look for the following line in the cgi-bin/opencart_file_upload.cgi file (line 115) and remove the comment (# sign) at the beginning of the line:

Code: Select all

    #select(undef, undef, undef, 0.03125);	# sleep for 1/32 of a second.  1Mbit throttle
to

Code: Select all

    select(undef, undef, undef, 0.03125);	# sleep for 1/32 of a second.  1Mbit throttle
What is your Use URL Alias set to?  Can you turn it off just to test it out?  Make sure to clear your browser cache after changing the setting.

Re: [RELEASED] - 0.7.9 File Upload

Posted: Thu Oct 16, 2008 9:40 am
by robgtheengineer
Apache version  2.0.63
PERL version 5.8.8
PHP version  5.2.6
MySQL version 5.0.51a-community
Turned off alias, still no luck.
I am using 0.7.9 rc2.

Re: [RELEASED] - 0.7.9 File Upload

Posted: Thu Oct 16, 2008 9:46 am
by randomfactor
robgtheengineer wrote: When I try to upload an image it either just sits there or gives me a bunch of junk, what do you think? http://123picturethis.com/index.php?con ... duct_id=21
Rob, your cgi-bin is not working.  It looks like your site is rewriting the url and redirecting to the OpenCart error page.

Your cgi-bin url:

    http://123picturethis.com/cgi-bin/openc ... f019097c08

should behave like this url:

    http://www.digispray.com/cgi-bin/openca ... f019097c08

Re: [RELEASED] - 0.7.9 File Upload

Posted: Thu Oct 16, 2008 9:55 am
by robgtheengineer
what would cause this?

Re: [RELEASED] - 0.7.9 File Upload

Posted: Thu Oct 16, 2008 12:54 pm
by randomfactor
robgtheengineer wrote: what would cause this?
I don't know.  The top of the suspect list would be your .htaccess file in  /home/capemb/public_html.

Can you verify that you have correctly located your localized perl uploading script at

    /home/capemb/public_html/opencart_file_upload.cgi

and that the file permissions on it are 0775?

Re: [RELEASED] - 0.7.9 File Upload

Posted: Thu Oct 16, 2008 6:37 pm
by robgtheengineer
Yeah everything is in the correct place.

Re: [RELEASED] - 0.7.9 File Upload

Posted: Thu Oct 16, 2008 7:07 pm
by Qphoria
Perhaps contact your webhost to see if they can figure it out. Sometimes its some mundane thing that you didn't realize. I know one host i had broke if you set your permissions higher than 755

Re: [RELEASED] - 0.7.9 File Upload

Posted: Thu Oct 16, 2008 7:54 pm
by robgtheengineer
It is not the permissions, I already talked to my host.  The weirdest thing is that when I installed the product option plugin, even without the upload, when I try to add anything to the cart,  it gives me php errors.  Should I try 0.7.8?

Re: [RELEASED] - 0.7.9 File Upload

Posted: Thu Oct 16, 2008 8:07 pm
by Qphoria
robgtheengineer wrote: Should I try 0.7.8?
this contrib was based on 0.7.9. using an older buggy version of opencart will not help. try a fresh install of rc2. then install only this contrib and see if that works.

if the error is cgibin tho, im inclined to think its still a webhost issue

Re: [RELEASED] - 0.7.9 File Upload

Posted: Thu Oct 16, 2008 8:22 pm
by robgtheengineer
This is the only one I installed.  Installing only the production option plugin breaks my cart.

Re: [RELEASED] - 0.7.9 File Upload

Posted: Thu Oct 16, 2008 8:45 pm
by randomfactor
robgtheengineer wrote: It is not the permissions, I already talked to my host.  The weirdest thing is that when I installed the product option plugin, even without the upload, when I try to add anything to the cart,  it gives me php errors.  Should I try 0.7.8?
Proposed experiment.  TEMPORARILY, move your top level .htaccess file to some other name.  Then hit the link to the cgi:

    http://123picturethis.com/cgi-bin/openc ... f019097c08

You should see this message (or something like it) in your browser:
The server encountered an unexpected condition which prevented it from fulfilling the request.
The script had an error or it did not produce any output. If there was an error, you should be able to see it in the error log.
In your server error log, you should see a message like this:
DBD::mysql::st execute failed: Column 'total_bytes' cannot be null at /home/capemb/public_html/cgi-bin/opencart_file_upload.cgi line 79.
That will at least indicate that control is being transferred to the cgi script and that it is being executed.  If you see your catalog site, then something out of your control is redirecting away from the cgi-bin.

Let me know what you find.

And don't forget to move the .htaccess file back into place afterwards.  ;)

Thanks!

Re: [RELEASED] - 0.7.9 File Upload

Posted: Thu Oct 16, 2008 8:53 pm
by randomfactor
robgtheengineer wrote: now when i try to add to cart i get the following error:

Warning: Invalid argument supplied for foreach() in /home/capemb/public_html/library/cart/product_option.php on line 251

Warning: Cannot modify header information - headers already sent by (output started at /home/capemb/public_html/library/cart/product_option.php:251) in /home/capemb/public_html/library/environment/response.php on line 23
Doh!  I'm sorry.  I've got a bug when there are NO options for the product.  Now, why didn't I think of testing that?!!

OK, I have a reproducible case and I am working on a patch...

Re: [RELEASED] - 0.7.9 File Upload

Posted: Thu Oct 16, 2008 8:59 pm
by Qphoria
HOW DARE YOU!  ;D

Good catch :)

Re: [RELEASED] - 0.7.9 File Upload

Posted: Thu Oct 16, 2008 9:06 pm
by randomfactor
Rob, edit .../library/cart/product_option.php and make the following change at line 248:

Change this:

Code: Select all

	// return error string array for invalid option values
	public static function validateProductOptions(&$locator, $product_id, $form_options) {
		$validation_errors = array();
		foreach ($form_options as $k => $v) {
			$opt = ProductOption::createByProductID($locator, $k, $product_id);
			if ($opt && ($err = $opt->validate($product_id, $v))) {
				$validation_errors[] = $err;
			}
		}
		return $validation_errors;
	}
To this:
// return error string array for invalid option values
public static function validateProductOptions(&$locator, $product_id, $form_options) {
$validation_errors = array();
if ($form_options) {
foreach ($form_options as $k => $v) {
$opt = ProductOption::createByProductID($locator, $k, $product_id);
if ($opt && ($err = $opt->validate($product_id, $v))) {
$validation_errors[] = $err;
}
}
}
return $validation_errors;
}
After a few more of my screwups like this are fixed, I'll post an updated zip for the contribution.  My apologies to those of you like Rob, who are playing along at home.