Hi All, sure this is simple but I'm still new to php/mySQL so errors are abundant!
I have a simple form with one input: a browse button so the user can find a .csv file on their computer. User then clicks button, upon which I would like the file to be read and the contents put into an array, and the values to be added to the database. I do not need the file to be stored (uploaded).
So far my code is not erroring, it just doesn't add the values to the db. I'm wondering if it's just that I HAVE to upload and save the file to the webserver else I can't read it?
if(isset($_FILES['file_path']['tmp_name'])&& $_FILES['file_path']['tmp_name'] !=''){
$file_to_import = $_FILES['file_path']['tmp_name'];
$import_data = file($file_to_import);
print_r($import_data);
if ($import_data !=''){
for($index = 1; $index < sizeof($import_data); $index++){
$order_data = explode(",",$import_data[$index]);
tep_db_query("UPDATE orders SET act_shipping_cost = '" . $order_data[8]. "' WHERE orders_id = '". $order_data[0]."'");
echo "done it";
}
}else{
echo 'error cant read file!';
}
} else{ ?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
etc etc etc
<form id="shipping_costs_upload" name="csv_file_reader" method="post" action="shipping_cost_upload.php">
<div class="main" id="info_text"><h2>Upload Actual Shipping Costs CSV</h2><p>To upload actual shipping cost data, browse to your csv and click the Upload Data button.<br /><br /></p>
<div class="date" id="file">
<strong>CSV File: </strong><input type="file" name="file_path" id="file_url" />
</div>
<div class="date"><input type="submit" value="Upload Data">
</div>
</form>
etc etc etc
Apologies if I'm being a complete dunce!