Forum Moderators: coopster
1. the file i choose to be uploaded, its name is not saved in my database (OOSystem.la_letter).
2. the function 'copy()' is not working.
3. 'is_uploaded_file()' is also not working.
what's wrong with my code?
can somebody have a look?
thanks..
<form method=post action="<?=$PHPSELF?>">
<p>UPLOAD TERMINATION LETTER TO MAMPU</p>
<p>Select File : <input type=file name="la_letter"></p>
<p><input type=submit name=submit_la_letter value="Upload" onClick="return rusure()"></p>
</form>
<?
if(isset($submit_la_letter))
{
if($submit_la_letter == 'Upload')
{
$sqlB = "select max(la_id) from la_letter where proj_code = '$proj_code' and site_code = '$site_code'";
$dbB = mysql_db_query($dbname,$sqlB,$dblink);
while($rowB = mysql_fetch_array($dbB))
{
$currentB = $rowB[0] + 1;
}
if (is_uploaded_file($la_letter))
{
$curbasepath = dirname($PATH_TRANSLATED);
$newname = $curbasepath."/LA_terminate_letter/".$HTTP_POST_FILES['la_letter']['name'];
if(copy($la_letter,$newname)) {echo "copy_ ok!";} else {echo "COPY_ fails";}
} else echo "copy fails";
$sqlSaveL = "insert into la_letter set la_id = '$currentB', proj_code = '$proj_code', site_code = '$site_code', la_file = '$la_letter_name', la_matter = 'TERMINATE'";
$dbL = mysql_db_query($dbname,$sqlSaveL,$dblink);
if($dbL) {echo "Upload OK!";} else {echo "upload fail!";}
}
}?>
and another thing, since the file attached is in *.doc format, how can the user view/see the attached document? i.e: when i click a link that leads to the name of the document, for example, how can i view it? will a program such as ms word or wordpad will open the document automatically?
i think it works ok if it is an image file (gif/jpg etc), but what about a letter which is in .doc format?