Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Uploading files

Status
Not open for further replies.

je150

IS-IT--Management
Jun 10, 2003
33
US
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 = &quot;/var/$newfile = $uploaddir . $filename;
if(copy($file, $newfile))
print(&quot;<h3> UPLOAD SUCCESSFUL!</h3>&quot;);
?>

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(&quot;Unable to connect to database&quot;);

mysql_select_db(&quot;$dbName&quot;) or die(&quot;Unable to select database&quot;);

print &quot;<center>&quot;;
print &quot;Data is Being Processed, please wait....&quot;;
print &quot;</center>&quot;;

/* File Upload Script */
if(isset($submit))
$uploaddir = &quot;/var/$newfile = $uploaddir . $filename;
if(copy($file, $newfile));

/* Insert information into table */
$today= date(&quot;m/d/Y h:i:s&quot;);
$query = &quot;insert into $userstable ( id, subject, importance, comment, time )&quot; .
&quot;values (&quot;.
&quot;'&quot; . mt_rand (10000, 999999) . &quot;',&quot; .
&quot;'&quot; . $subject . &quot;',&quot; .
&quot;'&quot; . $importance . &quot;',&quot; .
&quot;'&quot; . $comment . &quot;',&quot; .
&quot;'&quot; . $today . &quot;'&quot; .
&quot;)&quot;;


$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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top