rotaour Posted October 3, 2007 Share Posted October 3, 2007 I have slightly modified the SPPC contribution and am having trouble with one last detail, uploading a .csv file to the server. An explanation of my changes; I have removed the RA(request auth) functionality from SPPC in favor of a customer authorization method. I created TABLES_CUSTOMERS_GROUPS_AUTH which has an auth_id, customer_group_id, auth_email and auth_track field. In addition I have added an auto generated code to my customers group page which gets inserted into TABLE_CUSTOMERS_GROUPS upon creation of a new customer group. In order for this to work a client must give us a comma delimited(or something easily converted to csv) file including company email addresses for each person authorized to enter this group. These addesses get inserted into my TABLE_CUSTOMERS_GROUPS_AUTH. Once we have these email addys the access code will be emailed and/or disseminated however the client company feels appropriate. Customers can then create a new account or change an existing account to this customer group by entering the access code and their company email address in create_account.php or my change_customer_group.php file. These two things are checked against the DB and access granted or denied. If granted the auth_track field in TABLE_CUSTOMERS_GROUPS_AUTH is set to 1 and cannot be used to auth another user. Heres the code regarding the insert of entries from a csv file. I've pretty much copied the upload class stuff straight from the product_image upload code in categories.php. /////////////////////////////// The form field <td class="main"><?php echo tep_draw_file_field('upload_csv'); ?></td> /////////////////////////////// The upload, file read and insert case 'newconfirmmultiple' : $customers_group_id = tep_db_prepare_input($HTTP_POST_VARS['customers_group_id']); // $customers_group_name = tep_db_prepare_input($HTTP_POST_VARS['customers_group_name']); $upload_csv = tep_db_prepare_input($HTTP_POST_VARS['upload_csv']); if (isset($HTTP_POST_VARS['upload_csv']) && tep_not_null($HTTP_POST_VARS['upload_csv']) && ($HTTP_POST_VARS['upload_csv'] != 'none')) { $upload_csv = new upload('upload_csv'); $upload_csv->set_destination(DIR_FS_CSV); // $upload_csv = new upload('upload_csv', DIR_FS_CSV); tried, doesnt work if ($upload_csv->parse() && $upload_csv->save()) { $upload_csv_name = $upload_csv->filename; } $row = 1; $handle = fopen(DIR_FS_CSV . $upload_csv_name, "r"); while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $num = count($data); // echo "<p> $num fields in line $row: <br /></p>\n"; $row++; for ($c=0; $c < $num; $c++) { $customers_group_auth_email = $data[$c]; // echo $data[$c] . "<br />\n"; tep_db_query("insert into " . TABLE_CUSTOMERS_GROUPS_AUTH . " set customers_group_id = " . $customers_group_id . ", customers_group_auth_email = '" . $customers_group_auth_email . "'"); } } fclose($handle); } // tep_redirect(tep_href_link('wholesale_customers.php', tep_get_all_get_params(array('action')))); break; I have confirmed that the DIR_FS_CSV path is correct and set in the config. I think is has something to do with the naming. I did have it working with a static file name at one point, but would like to save each file for recording purposes. Just to be clear the file does not upload and the class returns a "Warning: No file uploaded." error. When it goes through the file read and inserts it inserts one field(out of 4 in the test file) with the value of ’š .ò§ ..“šèadd_wholesale.csv Anyone with a good OOP understanding have any ideas or suggestions for me? TIA Matt Mika Installed Contributions: Multi-Stores, QTPro, CCGV(trad), Batch Print, EasyPopulate, Simple Manual Order Entry, Encrypting Credit Card Via Mcrypt, UPSXML, Down for Maintenance, On The Fly GD Thumbs, SPPC, SPPC Hide, and various personal tweaks Link to comment Share on other sites More sharing options...
rotaour Posted October 3, 2007 Author Share Posted October 3, 2007 I noticed when printing out the upload Object there was no filename or tmp_filename vars. Which led me to believe the files wasnt being sent. Tada! I forgot to set the form enctype to multipart/form-data! I then need to change some $HTTP_POST_VARS in if statements to $HTTP_POST_FILES and chmod the destination dir. Works like a charm now. Matt Mika Installed Contributions: Multi-Stores, QTPro, CCGV(trad), Batch Print, EasyPopulate, Simple Manual Order Entry, Encrypting Credit Card Via Mcrypt, UPSXML, Down for Maintenance, On The Fly GD Thumbs, SPPC, SPPC Hide, and various personal tweaks Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.