Forum Moderators: coopster

Message Too Old, No Replies

$http_post_files

         

lisa_alias

2:01 pm on Jan 23, 2004 (gmt 0)

10+ Year Member



hi everyone.
i'm facing a problem related to file uploading (*.doc).
i'm using php 4 plus mysql.

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!";}
}
}?>

RussellC

2:08 pm on Jan 23, 2004 (gmt 0)

10+ Year Member



First step is to make sure your form tag looks like this:

<form method="POST" action="<?=$PHP_SELF?>" enctype="multipart/form-data" />

lisa_alias

2:45 pm on Jan 23, 2004 (gmt 0)

10+ Year Member



thanks 4 the help.. it works ok now.. :)

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?

RussellC

3:01 pm on Jan 23, 2004 (gmt 0)

10+ Year Member



If they are using IE and they have MS Word installed it will usually open up in the browser. If they are using a different browser it will probably ask them where they want to save it.

-Russell