You are here:  » Upload Script from Browser


Upload Script from Browser

Submitted by ROYW1000 on Tue, 2014-02-04 19:27 in

Hi

Do you have a ready made script like your demo which allows from the broswer the upload/submit option but actually submits the data to the database.

The upload file will be a known format.

Thanks
Roy

Submitted by support on Wed, 2014-02-05 08:39

Hello Roy,

It's straight forward to handle file uploads in PHP, so an outline script whereby you have a file upload HTML form with which to upload and parse a file would be as follows:

<?php
  set_time_limit(0);
  require("MagicParser.php");
  function myRecordHandler($record)
  {
    // process record as normal e.g. insert into MySQL
  }
  if (isset($_FILES['userfile']['tmp_name']))
  {
    MagicParser_parse($_FILES['userfile']['tmp_name'],"myRecordHandler","xml|FORMAT/STRING/");
  }
?>
<form enctype="multipart/form-data" method="POST">
  Select File:<br />
  <input name="userfile" type="file" />
  <input type="submit" value="Upload" />
</form>

Replace xml|FORMAT/STRING/ with the actual format of your source data, and that should get you close!

Cheers,
David
--
MagicParser.com