upload/import_doc.php

Go to the documentation of this file.
00001 <?php
00002   /*
00003    This file is part of DocBookWiki.  DocBookWiki is a web application
00004    that displays and edits DocBook documents.
00005 
00006    Copyright (C) 2004, 2005, 2006, 2007
00007    Dashamir Hoxha, dashohoxha@users.sourceforge.net
00008 
00009    DocBookWiki is free software; you can redistribute it and/or modify
00010    it under the  terms of the GNU General  Public License as published
00011    by the Free  Software Foundation; either version 2  of the License,
00012    or (at your option) any later version.
00013 
00014    DocBookWiki is distributed in the  hope that it will be useful, but
00015    WITHOUT  ANY  WARRANTY;  without   even  the  implied  warranty  of
00016    MERCHANTABILITY or  FITNESS FOR A PARTICULAR PURPOSE.   See the GNU
00017    General Public License for more details.
00018 
00019    You should have  received a copy of the  GNU General Public License
00020    along  with  DocBookWiki;  if  not,  write  to  the  Free  Software
00021    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00022    USA
00023   */
00024 
00031 function upload_files()
00032 {
00033   global $fnames, $upload_msg;
00034 
00035   //get the xml_file
00036   $tmp_name = $_FILES['xml_file']['tmp_name'];
00037   $file_name = $_FILES['xml_file']['name'];
00038   $xml_file = basename($file_name);
00039   $dest_file = "content/initial_xml/uploaded/$xml_file";
00040   $msg = check_upload_status('xml_file');
00041   if ($msg=='')  $msg = move_file($tmp_name, $dest_file);
00042 
00043   //set the global variables
00044   $fnames = $xml_file;
00045   $upload_msg = $msg;
00046 
00047   //if there is no media_files, return
00048   $file_name = $_FILES['media_files']['name'];
00049   if ($file_name=='')  return;
00050 
00051   //get the media_files
00052   //the destination file has the same basename as the xml_file,
00053   //but with extension .media.tgz instead of .xml
00054   $tmp_name = $_FILES['media_files']['tmp_name'];
00055   $media_files = ereg_replace('\.xml$', '.media.tgz', $xml_file);
00056   $dest_file = "content/initial_xml/uploaded/$media_files";
00057   $msg = check_upload_status('media_files');
00058   if ($msg=='')  $msg = move_file($tmp_name, $dest_file);
00059 
00060   //update the global variables
00061   $fnames .= ', '.$media_files;
00062   $upload_msg .= "<br/>\n".$msg;
00063 }
00064 ?>

Generated on Wed Jan 9 08:27:32 2008 for DokBookWiki by  doxygen 1.5.2