Subversion Repositories computer_asset_manager_v1

Rev

Rev 58 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 58 Rev 59
Line 2... Line 2...
2
   include_once( '../../header.php' );
2
   include_once( '../../header.php' );
3
   include_once( './functions.php' );
3
   include_once( './functions.php' );
4
 
4
 
5
   $result = '';
5
   $result = '';
6
   $debug = '';
6
   $debug = '';
7
   if ( isset( $_REQUEST['uploaddocument'] ) ) {
7
   if ( isset( $_REQUEST['uploadfile'] ) ) {
8
      // clean up the input first
8
      // clean up the input first
9
      $client_id = cleanInput( $_REQUEST['client_id'] );
9
      $client_id = cleanInput( $_REQUEST['client_id'] );
10
      $site_id = cleanInput( $_REQUEST['site_id'] );
10
      $site_id = cleanInput( $_REQUEST['site_id'] );
11
      $device_id = cleanInput( $_REQUEST['device_id'] );
11
      $device_id = cleanInput( $_REQUEST['device_id'] );
12
      $name = cleanInput( $_REQUEST['name'], $_FILES['fileToUpload']['name'] );
12
      $name = cleanInput( $_REQUEST['name'], $_FILES['fileToUpload']['name'] );
Line 42... Line 42...
42
      // at this point, we have 12/34/123456-c-Walder IP Law.csv
42
      // at this point, we have 12/34/123456-c-Walder IP Law.csv
43
      if ( $result['valid'] ) {
43
      if ( $result['valid'] ) {
44
         $nameOnDisk = $result['filename'];
44
         $nameOnDisk = $result['filename'];
45
         $saveTo = getAbsolutePath( $nameOnDisk );
45
         $saveTo = getAbsolutePath( $nameOnDisk );
46
         // $saveT now has document root, etc... prepended, so
46
         // $saveT now has document root, etc... prepended, so
47
         // /var/www/computer_asset_management/modules/documents/file_storage/12/34/123456-c-Walder IP Law.csv
47
         // /var/www/computer_asset_management/modules/files/file_storage/12/34/123456-c-Walder IP Law.csv
48
         if ( makePath( $saveTo ) ) {
48
         if ( makePath( $saveTo ) ) {
49
            $result = "Path Made - $saveTo";
49
            $result = "Path Made - $saveTo";
50
            if ( ( move_uploaded_file( $_FILES["fileToUpload"]["tmp_name"], $saveTo ) ) ) {
50
            if ( ( move_uploaded_file( $_FILES["fileToUpload"]["tmp_name"], $saveTo ) ) ) {
51
               $result = addDocument(
51
               $result = addfile(
52
                              $nameOnDisk,
52
                              $nameOnDisk,
53
                              $device_id, 
53
                              $device_id, 
54
                              $client_id, 
54
                              $client_id, 
55
                              $site_id,
55
                              $site_id,
56
                              isset( $_REQUEST['mime_type'] ) ? $_REQUEST['mime_type'] : $_FILES["fileToUpload"]['type'],
56
                              isset( $_REQUEST['mime_type'] ) ? $_REQUEST['mime_type'] : $_FILES["fileToUpload"]['type'],
57
                              $name,
57
                              $name,
58
                              $description
58
                              $description
59
                           );
59
                           );
60
               $result = $result === null ? "Could not add document<br />$nameOnDisk<br />to database" : 'Success';
60
               $result = $result === null ? "Could not add file<br />$nameOnDisk<br />to database" : 'Success';
61
            } else {
61
            } else {
62
               $result = "Failed to upload to disk<br />$saveTo";
62
               $result = "Failed to upload to disk<br />$saveTo";
63
            } // if move_uploaded_file .. else
63
            } // if move_uploaded_file .. else
64
         } else {
64
         } else {
65
            $result = "failed to make path<br />$saveTo";
65
            $result = "failed to make path<br />$saveTo";
66
         }
66
         }
67
      } else {
67
      } else {
68
         $result = $result['message'];
68
         $result = $result['message'];
69
      } // if nameOnDisk .. else
69
      } // if nameOnDisk .. else
70
   } // if isset uploaddocument
70
   } // if isset uploadfile
71
?>
71
?>
72
<?xml version="1.0" encoding="utf-8"?>
72
<?xml version="1.0" encoding="utf-8"?>
73
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
73
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
74
<html xmlns="http://www.w3.org/1999/xhtml">
74
<html xmlns="http://www.w3.org/1999/xhtml">
75
<head>
75
<head>
Line 81... Line 81...
81
<div id="content">
81
<div id="content">
82
   <?php 
82
   <?php 
83
      if ( isset( $result ) ) print "<h3>$result</h3>";
83
      if ( isset( $result ) ) print "<h3>$result</h3>";
84
      //if ( isset( $debug ) ) print "<h3>$debug</h3>";
84
      //if ( isset( $debug ) ) print "<h3>$debug</h3>";
85
    ?>
85
    ?>
86
   <p>Choose only <b>one</b> of device, site or client to add the document to</p>
86
   <p>Choose only <b>one</b> of device, site or client to add the file to</p>
87
  <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
87
  <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
88
    <input type="hidden" name="MAX_FILE_SIZE" value="100000" />
88
    <input type="hidden" name="MAX_FILE_SIZE" value="100000" />
89
    <table>
89
    <table>
90
       <tr>
90
       <tr>
91
          <td>
91
          <td>
Line 125... Line 125...
125
             Mime Type
125
             Mime Type
126
          </td>
126
          </td>
127
          <td>
127
          <td>
128
             <select name='mime_type_id' >
128
             <select name='mime_type_id' >
129
                <option value='0'>Autodetect</option>
129
                <option value='0'>Autodetect</option>
130
                <?php print queryToSelect("select document_mime_type_id, concat( extension, ' (', mime_type, ')') from document_mime_type order by extension" ); ?>
130
                <?php print queryToSelect("select file_mime_type_id, concat( extension, ' (', mime_type, ')') from file_mime_type order by extension" ); ?>
131
             </select>
131
             </select>
132
          </td>
132
          </td>
133
       </tr>
133
       </tr>
134
       <tr>
134
       <tr>
135
          <td>
135
          <td>
136
             Document Name
136
             file Name
137
          </td>
137
          </td>
138
          <td>
138
          <td>
139
             <input type="text" name="name" size="30" maxlength="64" />
139
             <input type="text" name="name" size="30" maxlength="64" />
140
          </td>
140
          </td>
141
       </tr>
141
       </tr>
Line 155... Line 155...
155
             <input name="fileToUpload" type="file" />
155
             <input name="fileToUpload" type="file" />
156
          </td>
156
          </td>
157
       </tr>
157
       </tr>
158
       <tr>
158
       <tr>
159
          <td colspan='2' align="center">
159
          <td colspan='2' align="center">
160
             <input type="submit" name="uploaddocument" value="Upload" />
160
             <input type="submit" name="uploadfile" value="Upload" />
161
          </td>
161
          </td>
162
       </tr>
162
       </tr>
163
    </table>
163
    </table>
164
  </form>
164
  </form>
165
</div>
165
</div>