[CONTRIBUTION] File uploads as an Option Feature
#1
Posted 23 September 2003 - 08:27 PM
Thanks,
Matt
#2
Posted 23 September 2003 - 08:30 PM
#3
Posted 23 September 2003 - 08:45 PM
Essentially, this adds a file type to the existing four ways of displaying the attributes for a product with the Products Attributes - Option Type Feature contribution (drop down menu, text box, radio buttons, check box). One can use the standard HTML FILE input field (the one with the browse button) to upload a file to the server. The contribution will then rename it uniquely and store the original and new names in a database table.
The idea is so that you can upload logos, etc. for placement on things like mugs, t-shirts, and so forth. If you want different kinds of files, you might have to modify the code somewhat.
Hth,
Matt
#4
Posted 24 September 2003 - 01:29 AM
I just need to clarify, before I go and install this one . . .
Is it the customer that can upload the file so it is available to the admin? OR
Is it the admin that uploads the file so that it is available to the customer?
Regards,
Jarrod
#5
Posted 24 September 2003 - 02:57 AM
#6
Posted 24 September 2003 - 05:47 AM
this is what i was searching for the last year...GREAT!
iŽll try it now...
#7
Posted 24 September 2003 - 08:17 PM
if i upload an image it is saved as a file without any extension.
the files are stored as "1", "2"... instead of "1.jpg" or "2.gif"
whats the reason? maybe i did a mistake while the installation?
hope for fast help!
#8
Posted 25 September 2003 - 12:32 AM
Morbantokk, on Sep 24 2003, 04:17 PM, said:
whats the reason? maybe i did a mistake while the installation?
$products_options_file->set_filename("$insert_id");to (for example) $products_options_file->set_filename("$insert_id" . $products_options_file->filename);
Hth,Matt
#9
Posted 25 September 2003 - 12:38 AM
jarrodcoyles, on Sep 23 2003, 09:29 PM, said:
Is it the admin that uploads the file so that it is available to the customer?
Hth,
Matt
#10
Posted 25 September 2003 - 06:05 AM
iiinetworks, on Sep 25 2003, 01:32 AM, said:
Morbantokk, on Sep 24 2003, 04:17 PM, said:
whats the reason? maybe i did a mistake while the installation?
$products_options_file->set_filename("$insert_id");to (for example) $products_options_file->set_filename("$insert_id" . $products_options_file->filename);
Hth,Matt
but the next wish i have is to allow only some file extensions like gif or jpg...
the user shouldnŽt upload zip-files or whatever...
i want only graphic and vektor-files..
how can i realise this?
Ron
#11
Posted 25 September 2003 - 06:49 AM
and it works.
iŽve changed the classes/upload.php
old code:
function upload($file = '', $destination = '', $permissions = '777', $extensions = '') {
new code:
function upload($file = '', $destination = '', $permissions = '777', $extensions = array("jpg", "jpeg", "gif", "png", "eps", "cdr", "ai", "pdf")) {
iŽm happy
but, iiinetworks: what do you think when the error-messages like "wrong filetype" are ready for use?
#12
Posted 25 September 2003 - 10:57 AM
and excellent remark about file extension. Think of security issues: imagine someone uploading e.g. a php file (or any serverside executable file) and assuming that execute permission exists on upload target directory: could be harmfull !
Regards
#13
Posted 26 September 2003 - 05:27 PM
dugs, on Sep 25 2003, 06:57 AM, said:
, $permissions = '666',two, add the $extensions default as suggested above (same line); three, copy the .htaccess file from the includes directory to the upload directory. Note: each of these is a separate (albeit related) vulnerability, so one should do all three rather than just one. I'll look into adding these in a replacement upload sometime next week, probably with a revised .htaccess file.
Hth,
Matt
Edited by iiinetworks, 26 September 2003 - 05:28 PM.
#14
Posted 26 September 2003 - 05:35 PM
Morbantokk, on Sep 25 2003, 02:49 AM, said:
Hth,
Matt
#15
Posted 27 September 2003 - 10:52 AM
iŽve tried to copy the file to my classes but it doesn`t work...
what can i do?
#16
Posted 28 September 2003 - 02:40 PM
Just to let you know, I find it unlikely at the moment that I will undertake a project to backport the messages to older snapshots. In fact, unless it is simple, it may be a while before I get around to making messages work for MS2.
Good luck,
Matt
#17
Posted 28 September 2003 - 04:29 PM
#18
Posted 29 September 2003 - 09:09 AM
In application_top.php I see $products_options_file->set_destination(DIR_FS_UPLOAD); ; but in configure.php I see define('DIR_FS_UPLOADS', DIR_FS_CATALOG . DIR_WS_UPLOADS);
And of course when I add my item (with file input option) to my cart I get: Not writeable! DIR_FS_UPLOAD:
Changing to DIR_FR_UPLOAD (with no S at end) in configure.php helps.
Besides, In configure.php, code has been changed compared to OSC original file from define('DIR_FS_CATALOG', dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME'])); to define('DIR_FS_CATALOG', $FS_DOCUMENT_ROOT . DIR_WS_HTTP_CATALOG);. I reset this back to original code to have contrib working, ... but I was wondering why these changes... ?
#19
Posted 06 October 2003 - 11:04 AM
I have noticed one problem though. In the admin area when I try to change the "Value Price" for the upload (or any option) I get a SQL error:
Quote
select products_options_type fro products_options where products_options_id = '3'
Any idea if this is just a problem on my system or how I would go about debugging it?
#20
Posted 06 October 2003 - 11:14 AM
Just change "fro" to "from" in about line 134 in product_attributes.php in the admin code.









