Morbantokk Posted October 18, 2003 Share Posted October 18, 2003 iiinetworks: its me again.. i have an idea... maybe it would be useful to add a "filesize-check" to the upload.php so you could limit the max upload-filesize... i think this would be very useful.. maybe you can realize this? greets from germany.. Quote WAR is not the answer! Link to comment Share on other sites More sharing options...
Guest Posted October 19, 2003 Share Posted October 19, 2003 To limit upload size, try adding something like php_value('upload_max_filesize', '2M'); to the .htaccess file (or the appropriate DIRECTORY section in httpd.conf) or php.ini. In regards Message Stack, try moving the $messageStack declaration higher. You can use a diff program on application_top.php between the current and previous versions of the contribution to see what I had to change. You may have missed this change earlier. Without it, it doesn't work. Hth, Matt Quote Link to comment Share on other sites More sharing options...
Morbantokk Posted October 20, 2003 Share Posted October 20, 2003 ok. thanks. i?ll test a little bit. Quote WAR is not the answer! Link to comment Share on other sites More sharing options...
Morbantokk Posted October 20, 2003 Share Posted October 20, 2003 the message_stack runs now in my MS1. i?ve found the error in my application_top. i had installed other contribs which using the "require(DIR_WS_CLASSES . 'boxes.php')" it was called 2 times in application_top. so it crashed... i deleted opne of this to requires and it runs now ;) to my filesize-ask: i like to have the filesize-check as a part of the upload-class. so if a user wants to uplaod a too big file a messages_stack "error: file too big" occurs.. you understand what i mean? my english isn?t really good... Quote WAR is not the answer! Link to comment Share on other sites More sharing options...
Guest Posted October 21, 2003 Share Posted October 21, 2003 to my filesize-ask: i like to have the filesize-check as a part of the upload-class. so if a user wants to uplaod a too big file a messages_stack "error: file too big" occurs.. To do this properly, you would want to do it client side (possibly in javascript). Unfortunately, I am not much with javascript, so I would be little help to you here. The problem is that any check that I would put into the upload class would come *after* the upload was blocked by the upload_max_filesize. In fact, the check would occur after the file was uploaded (assuming it is smaller than upload_max_filesize). The best that PHP could do would be to upload the file and then delete it if it was too big (but smaller than the upload_max_filesize setting). The code to limit to 300KB would look something like this (the first and last lines are 72 and 73 in my copy of upload.php; the code in between is new): if ( tep_not_null($file['tmp_name']) && ($file['tmp_name'] != 'none') && is_uploaded_file($file['tmp_name']) ) { if (tep_not_null($file['size']) and ($file['size'] > 307200)) { if ($this->message_location == 'direct') { $messageStack->add('upload', ERROR_FILE_TOO_BIG, 'error'); } else { $messageStack->add_session('upload', ERROR_FILE_TOO_BIG, 'error'); } return false; } if (sizeof($this->extensions) > 0) { What I think would be more in keeping with what you want would be to add a javascript validation that would check the file size *before* upload and throw an error ("File too big.") on large files (avoiding wasting time uploading a large file just to delete it and throwing the error even if the file is larger than upload_max_filesize). If someone wants to write something like this, I would be happy to include it in future versions of the contribution. Hth, Matt Quote Link to comment Share on other sites More sharing options...
Morbantokk Posted October 21, 2003 Share Posted October 21, 2003 (edited) hi again, thanks for your help!!! your code is perfect...if the file is too big the error-message comes and the too big file isn?t uploaded!!!!! the file will only uploaded if the filesize is ok Edited October 21, 2003 by Morbantokk Quote WAR is not the answer! Link to comment Share on other sites More sharing options...
Morbantokk Posted October 21, 2003 Share Posted October 21, 2003 if the file is too big the error-message comes and the too big file isn?t uploaded!!!!! the file will only uploaded if the filesize is ok oh, sorry, i was wrong... yes, first the upload runs and after it the check of the filesize... on my local installation on my pc it seemed to run.. but a local upload runs within 1 second..but online i see the real upload-time... Quote WAR is not the answer! Link to comment Share on other sites More sharing options...
jippolit Posted October 25, 2003 Share Posted October 25, 2003 A couple really basic installation questions. 1. In Step 1 of your install doc you say: "Add the following fields to table products_options You can either use the enclosed option_type_feature.sql or the following definitions" So, if I use the "option_type_feature.sql" file on a new install, how do I "use" it to apply these changes. Or if I manually apply the changes, how do I apply them. For example, I assume these are applied to the data.sql file... right? Again same question for "Add the following field to table customer_basket_attributes". How do I add it (text editor-notepad?), and to exactly which file--and or which part of the file? 2. In step 3 you say to "Set up your TEXT Option Value." Again, if I want to use the enclosed insert_text_option_value.sql, how do I use this file to apply changes, and to what exact file do I need to apply these changes? I have gotten it installed to the point that when I try to add an option from the Admin Product options (using the pull down menu to select file) I get this error after I click insert: 1054 - Unknown column 'products_options_type' in 'field list' insert into products_options (products_options_id, products_options_name, language_id, products_options_type) values ('6', 'Test File Option 1', '1', '4') Any thoughts? Sorry for the really basic questions... Thanks! Quote Link to comment Share on other sites More sharing options...
jippolit Posted October 26, 2003 Share Posted October 26, 2003 A couple really basic installation questions. 1. .... DISREGARD the previous post by me. I have everything installed and working--almost... (first mySQL database for me) One quick question. I am not getting a text box on my final product page--or more importantly to me--a file upload box. I am getting a pull down menu that displays the option value and price. (i.e.) Photo: (+$1.00) where (+$1.00) shows in the pull down menu (in the actual store). Any thoughts on how to change this into an upload box with a browse button? Thanks. Joe Quote Link to comment Share on other sites More sharing options...
Guest Posted October 26, 2003 Share Posted October 26, 2003 In admin, did you select the option to be of type FILE? Did you edit the product_info.php page to include the new code that handles the FILE type? Is everything spelled correctly (a single spelling inconsistency could cause the code to misoperate). Have you added the defines to includes/configure.php? Hth, Matt Quote Link to comment Share on other sites More sharing options...
jippolit Posted October 27, 2003 Share Posted October 27, 2003 In admin, did you select the option to be of type FILE? Did you edit the product_info.php page to include the new code that handles the FILE type? Is everything spelled correctly (a single spelling inconsistency could cause the code to misoperate). Have you added the defines to includes/configure.php? Hth, Matt OK, Thanks! I was missing one line in a config file that I didn't catch the first 30 or so times :-) I almost have it working now. When I add a product with an option type of TEXT or FILE, and an option value of the same (which I have to manually type in the option values panel before inserting--in case that is not right) everything seems to work right. However, when I am using the shopping cart to add text or upload a file, the text and/or file name--or--path--or--image (i don't know which should display in the cart) does not pass into the shopping cart. BUT, if I add a check box option type with an option value of text, the text "- Check Text" displays under the product name in the Product(s) column in my shopping cart. So, it seems that I am not uploading the files or passing on this information, and likewise with the text field. Where should I investigate possible causes? Also, where is the default uploads/ directory usually? In the catalog/includes/config.php file, the last 2 lines do not need to be edited, do they? mine look like this: define('DIR_WS_UPLOADS', DIR_WS_IMAGES . 'uploads/'); define('DIR_FS_UPLOADS', DIR_FS_CATALOG . DIR_WS_UPLOADS); ?> Thanks!!!!!!!!!! joe Quote Link to comment Share on other sites More sharing options...
Guest Posted October 27, 2003 Share Posted October 27, 2003 You have to create an uploads directory. The suggested path is catalog/images/uploads. The directory would need to be chmod 777. Every time I've gotten the blank attribute in the shopping cart, which looks like this: product name- instead of product name- 8. image.jpg it was caused by a problem with the PRODUCTS_OPTIONS_VALUE_TEXT_ID. Remember that the value in the define needs to match the value of the products_options_values_id for your TEXT value in the database. This will be shown on the admin > Catalog > Products Attributes page in the Options Values table; look in the ID column for the row(s) with Option Value TEXT. All rows should have the same ID. Note: the products_attributes.php provided should maintain this value in the Options Values table automatically. If the define was wrong, you might have to delete all the TEXT Options and Attributes and put them back after the define is corrected. Btw, if you have already created the uploads directory in the images directory, it might have uploaded even if it didn't carry the filename info. Hth, Matt Quote Link to comment Share on other sites More sharing options...
jippolit Posted November 4, 2003 Share Posted November 4, 2003 OK, one more time please. I totally uninstalled everything, and deleted the database--things got to messy. On a fresh install, I am able to have everything act the way it should except 2 things: 1. When I browse for an image to upload, when adding it to my cart, it acts like it is working, but the file does not upload--I checked w/ftp, AND 2. No (visible) information passes to the cart description. Neither a "-" nor a file name appears under the product description. I have gone throught the full setup procedure so many times, and I don't know where to look . Suggestions of specific areas to look? Thanks. Joe Quote Link to comment Share on other sites More sharing options...
Guest Posted November 5, 2003 Share Posted November 5, 2003 I uploaded a new version (.75) with a revised install procedure (more weight on the database configuration). No new functionality has been added, so those who already have the contribution installed will receive no benefit from installing this one. Hth, Matt Quote Link to comment Share on other sites More sharing options...
Guest Posted November 5, 2003 Share Posted November 5, 2003 I think that I reintroduced some bugs with the latest version. I will probably be releasing a .76 sometime in the next week to clean them out. I'll make sure that I actually install it then, so this doesn't happen again. Thanks, Matt Quote Link to comment Share on other sites More sharing options...
jippolit Posted November 9, 2003 Share Posted November 9, 2003 Upload files size Limitation? Is there a limitation to how large a file can be with the FILE upload? When I add an image to the cart, it uploads fine if it is small, even like 2mb. My problem is not that I need to limit the file size, rather, I need to upload very large image files. When I try to upload a large image, like 12mb or 25mb, it of course takes forever, but when it finishes, the product option info, like the id & file name do not show up under the product description in the cart--as they do with the smaller images. Oh, and no, the large files are not actually uploaded in the uploads directory either. Any thoughts on what is causing this. P.S. Great contribution... Thanks! joe Quote Link to comment Share on other sites More sharing options...
Guest Posted November 10, 2003 Share Posted November 10, 2003 There is a configuration option in php.ini for this. You can fix it in any of php.ini, httpd.conf, or .htaccess. In .htaccess, you would say something like this: php_value upload_max_filesize 50M to increase the limit to 50 megabytes. Note: if this is the problem, you should be able to upload images smaller than the current limit, which you can look up from admin > Tools > Server Info Hth, Matt Quote Link to comment Share on other sites More sharing options...
gphillips Posted November 12, 2003 Share Posted November 12, 2003 Hi, First of all, great contribution, just what I was looking for, thank you sincerely. Now, if I can just get it working.... My PHP skills are virtually non-existent (but fast improving to poor), but I think there are a couple of typos which stop it even having a chance to work. First, the configure.php define is suggested as define('DIR_WS_UPLOADS', DIR_WS_IMAGES . 'uploads/'); yet the directory supplied is "upload". I think the two should match so either rename upload to uploads or change the 'uploads/' to 'upload/' Then there is a parse error on line 74 of upload.php. if (tep_not_null($file['size']) and ($file['size'] > 307200) { Initially I thought this was because of the "and" instead of "&&" but I blive it's because of a missing bracket i.e. if (tep_not_null($file['size']) && ($file['size'] > 307200)) { Hope this is right, upload.php at least parses with that. Now, my problem. Having set everything up in admin for an upload product I add to cart, it seems to take some time indicating that it IS uploading my file but then it returns with "Error Destination does not exist" Has anyone else had this. Is that extra bracket in the wrong place??? Any help greatly appreciated. I have the upload directory in place under images, the define matches it and it is chmod to 777. I'm a bit lost. Regards Glenn Quote Link to comment Share on other sites More sharing options...
Guest Posted November 12, 2003 Share Posted November 12, 2003 Hi, To save anyone any trouble, I've figured out what the issue was. There is a missing "S" Applocation_top_php in DIR_FS_Upload, which is defined as DIR_FS_Uploads in configure.php. It all works great now. Glenn Quote Link to comment Share on other sites More sharing options...
jippolit Posted November 12, 2003 Share Posted November 12, 2003 In .htaccess, you would say something like this: php_value upload_max_filesize 50M to increase the limit to 50 megabytes. This simple .htaccess change works great ! I tested uploading a 25M file with no problems yesterday... Thanks again Matt... Quote Link to comment Share on other sites More sharing options...
Guest Posted November 12, 2003 Share Posted November 12, 2003 One little thing. Any tips on how to figure out which uploaded file(s) belong to which customers order? Everyone must want to do this, it would be ideal if theoder ID was stamped on the files uploaded table I guess? Any suggestions? Glenn Quote Link to comment Share on other sites More sharing options...
Guest Posted November 12, 2003 Share Posted November 12, 2003 By default, if you look at the attributes in the customer's order, it will show #. image.ext. The number is the file name of the image and the files_uploaded_id. To go the other way, issue a SELECT orders_id FROM orders_products_attributes WHERE products_options_values IS LIKE 1.% Replace 1 with the actual files_uploaded_id. Hth, Matt Quote Link to comment Share on other sites More sharing options...
Guest Posted November 12, 2003 Share Posted November 12, 2003 Matt, Ahh yes, I see. thanks a lot. Glenn Quote Link to comment Share on other sites More sharing options...
gphillips Posted November 13, 2003 Share Posted November 13, 2003 One last, last thing, any thoughts on how to make the entering of a file upload compulsory, i.e. so that the user cannot add to cart unless uploding a file? Glenn Quote Link to comment Share on other sites More sharing options...
Guest Posted November 14, 2003 Share Posted November 14, 2003 To make all file uploads compulsory, change the following around lines 389-91 of includes/application_top.php } else { // No file uploaded -- use previous value $real_ids[TEXT_PREFIX . $HTTP_POST_VARS[UPLOAD_PREFIX . $i]] = $HTTP_POST_VARS[TEXT_PREFIX . UPLOAD_PREFIX . $i]; } to } else { // No file uploaded -- don't add to cart unless the value is already there if (tep_not_null($HTTP_POST_VARS[TEXT_PREFIX . UPLOAD_PREFIX . $i])) { $real_ids[TEXT_PREFIX . $HTTP_POST_VARS[UPLOAD_PREFIX . $i]] = $HTTP_POST_VARS[TEXT_PREFIX . UPLOAD_PREFIX . $i]; } else { break 2; } } You can add error messages there as well if you like. V .71 and higher should include $messageStack by that point. Hth, Matt Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.