602SQL Documentation Index  



boolean wb_import_file( resource connection, string file_name, string transfer_object_name )


The connection identifier returned by the wb_connect or wb_pconnect function.
Variable with the file name that was selected by the user from a a browser using the INPUT type=file tag.
Name of the database object with the data transfer description (Transfer object type).


This function allows you to read the file_name data file (sent by an HTML form) into a database (import data into a table). A Data transfer type object must be prepared in the application prior to the actual import. The name of this object is passed in the transfer_object_name parameter. This usually assumes a certain format of the file_name file (e.g. CSV).

Two-way transfers (Database <--> XML files) cannot be executed with this function. A description of these transfers can be found on the XML transfers in the PHP interface page.


TRUE if successful, otherwise FALSE.


HTML code of the form sending (uploading) a file with a suitable table and data transfer object import_test9 in the $appl application):

<form enctype="multipart/form-data" method="POST" action="upload_file.php" >
Choose the file: <input type="FILE" name="upl_file"> <br>
The file must be in the CSV format structure specified by the documentation!<br><br>
<input type="SUBMIT" value="Send">

Excerpt of the script upload_file.php:

echo "<h1>upload_file: ".$_FILES["upl_file"]['name']."</h1>";
echo "<br>type: ".$_FILES["upl_file"]['type'];
echo "<br>size: ".$_FILES["upl_file"]['size'];

$conn=wb_connect($dsn, $appl, $dbuser);
if ($conn){
 $result = wb_import_file($conn, $_POST["upl_file"], "import_test9");
 if ($result) {echo "<br><br>Data imported!";}
  else {echo "<br><br>Import failed!";}