Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Upload a File in PHP

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Upload a File in PHP

Postby jpizzolato » Tue Feb 18, 2014 11:13 pm

I am trying to upload a csv file to a website that was created using a MySQL query in a php file. Here is the code:
*************************************
// Fetch Record from Database

$output = "";
$table = "customer"; // Enter Your Table Name
$sql = mysql_query("select * from $table");
$columns_total = mysql_num_fields($sql);

// Get The Field Name

for ($i = 0; $i < $columns_total; $i++) {
$heading = mysql_field_name($sql, $i);
$output .= '"'.$heading.'",';
}
$output .="\n";

// Get Records from the table

while ($row = mysql_fetch_array($sql)) {
for ($i = 0; $i < $columns_total; $i++) {
$output .='"'.$row["$i"].'",';
}
$output .="\n";
}

// Download the file

$filename = "myFile.csv";
header('Content-type: application/csv');
header('Content-Disposition: attachment; filename='.$filename);

echo $output;
exit;
*****************************************
All this code is doing is displaying the results in the browser.
My problem is how do I get the myFile.csv uploaded to the following directory:
http://eztiffin.com/fileuploads/

Any help would be appreciated. thanks
jpizzolato
New php-forum User
New php-forum User
 
Posts: 1
Joined: Tue Feb 18, 2014 10:59 pm

Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 4 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.