I am currently working on an upload script that places a file in a folder on my hard disk. Alone, this script works, but when i paste it in my main script, the database record is still written however the file is not uploaded. I would also like any suggestions that would help with the creation of a document routing system. Basically, uploade a file with given information, and email a link out to select people that grants them access to that file and also logs who has read it. Bit of a project.
This is the upload script
<?php
if(isset($submit))
$uploaddir = "/var/$newfile = $uploaddir . $filename;
if(copy($file, $newfile))
print("<h3> UPLOAD SUCCESSFUL!</h3>"
;
?>
And this is it embedded, however, it doesnt work once placed like this
<?php
/* make connection to database */
mysql_connect($hostname,$username,$password) or die("Unable to connect to database"
;
mysql_select_db("$dbName"
or die("Unable to select database"
;
print "<center>";
print "Data is Being Processed, please wait....";
print "</center>";
/* File Upload Script */
if(isset($submit))
$uploaddir = "/var/$newfile = $uploaddir . $filename;
if(copy($file, $newfile));
/* Insert information into table */
$today= date("m/d/Y h:i:s"
;
$query = "insert into $userstable ( id, subject, importance, comment, time )" .
"values (".
"'" . mt_rand (10000, 999999) . "'," .
"'" . $subject . "'," .
"'" . $importance . "'," .
"'" . $comment . "'," .
"'" . $today . "'" .
"
";
$result = mysql_query($query);
/* Close the database connection */
mysql_close();
?>
All the variables are set and work separately, but the upload part doesnt work when place like above, any hints would be appreciated. Thanks
This is the upload script
<?php
if(isset($submit))
$uploaddir = "/var/$newfile = $uploaddir . $filename;
if(copy($file, $newfile))
print("<h3> UPLOAD SUCCESSFUL!</h3>"
?>
And this is it embedded, however, it doesnt work once placed like this
<?php
/* make connection to database */
mysql_connect($hostname,$username,$password) or die("Unable to connect to database"
mysql_select_db("$dbName"
print "<center>";
print "Data is Being Processed, please wait....";
print "</center>";
/* File Upload Script */
if(isset($submit))
$uploaddir = "/var/$newfile = $uploaddir . $filename;
if(copy($file, $newfile));
/* Insert information into table */
$today= date("m/d/Y h:i:s"
$query = "insert into $userstable ( id, subject, importance, comment, time )" .
"values (".
"'" . mt_rand (10000, 999999) . "'," .
"'" . $subject . "'," .
"'" . $importance . "'," .
"'" . $comment . "'," .
"'" . $today . "'" .
"
$result = mysql_query($query);
/* Close the database connection */
mysql_close();
?>
All the variables are set and work separately, but the upload part doesnt work when place like above, any hints would be appreciated. Thanks