Rev 1 | Rev 55 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
<?php
include_once( '../../header.php' );
include_once( './functions.php' );
$result = '';
if ( isset( $_REQUEST['uploaddocument'] ) ) {
$client_id = isset( $_REQUEST['client_id'] ) ? $_REQUEST['client_id'] : '';
$site_id = isset( $_REQUEST['site_id'] ) ? $_REQUEST['site_id'] : '';
$device_id = isset( $_REQUEST['device_id'] ) ? $_REQUEST['device_id'] : '';
$result = makeFileName(
$_FILES['fileToUpload']['name'],
$device_id,
$client_id,
$site_id
);
if ( $result['valid'] ) {
$nameOnDisk = $result['filename'];
makePath( $nameOnDisk );
$result = "<br />$nameOnDisk";
/*
* if ( makePath( $nameOnDisk ) ) {
$result = 'Path Made - ';
} else {
$result = 'failed to make path - ';
}
$result .= $nameOnDisk;
$path = $_SERVER['DOCUMENT_ROOT'] . '/' . pathinfo( $nameOnDisk, PATHINFO_DIRNAME );
$result .= $path;
/*
if ( ( move_uploaded_file( $_FILES["fileToUpload"]["tmp_name"], $nameOnDisk ) ) ) {
$result = addDocument(
$nameOnDisk,
$device_id,
$client_id,
$site_id,
isset( $_REQUEST['mime_type'] ) ? $_REQUEST['mime_type'] : $_FILES["fileToUpload"]['type'],
isset( $_REQUEST['name'] ) ? $_REQUEST['name'] : $_FILES['fileToUpload']['name'],
$_REQUEST['description']
);
$result = $result === null ? 'Could not add document to database' : 'Success';
} else {
$result = 'Failed to upload to disk';
} // if move_uploaded_file .. else
*/
} else {
$result = $result['message'];
} // if nameOnDisk .. else
} // if isset uploaddocument
?>
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Daily Data - Computer Asset Management Program</title>
<link rel="stylesheet" type="text/css" href="../../camp.css">
</head>
<body>
<?php include_once('../../menu.php'); ?>
<div id="content">
<?php if ( isset( $result ) ) print "<h3>$result</h3>"; ?>
<p>Choose only <b>one</b> of device, site or client to add the document to</p>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
<table>
<tr>
<td>
Attach To Device
</td>
<td>
<select name='device_id' >
<option value='0'>------------</option>
<?php print queryToSelect('select device_id, Device from view_current_client_systems order by Device' ); ?>
</select>
</td>
</tr>
<tr>
<td>
Attach To Site
</td>
<td>
<select name='site_id' >
<option value='0'>------------</option>
<?php print queryToSelect('select site_id, name from view_current_client_site order by name' ); ?>
</select>
</td>
</tr>
<tr>
<td>
Attach To Client
</td>
<td>
<select name='client_id' >
<option value='0'>------------</option>
<?php print queryToSelect('select client_id, name from view_current_client order by name' ); ?>
</select>
</td>
</tr>
<tr>
<td>
Mime Type
</td>
<td>
<select name='mime_type' >
<option value='0'>Autodetect</option>
<?php print queryToSelect("select document_mime_type_id, concat( extension, ' (', mime_type, ')') from document_mime_type order by extension" ); ?>
</select>
</td>
</tr>
<tr>
<td>
Document Name
</td>
<td>
<input type="text" name="name" size="30" maxlength="64" />
</td>
</tr>
<tr>
<td>
Description
</td>
<td>
<input type="text" name="description" size="30" />
</td>
</tr>
<tr>
<td>
Choose File
</td>
<td>
<input name="fileToUpload" type="file" />
</td>
</tr>
<tr>
<td colspan='2' align="center">
<input type="submit" name="uploaddocument" value="Upload" />
</td>
</tr>
</table>
</form>
</div>
</body>
</html>