Page 1 of 1

Upload Script Code

Posted: Mon Apr 14, 2003 2:58 pm
by knightmayor
Could someone please run over these codes and let me know where the error is and how I could correct it.

[Upload Form]
<div align=center width=98%><FORM ACTION="upload.php" METHOD="POST" ENCTYPE="multipart/form-data">
<CENTER>
<TABLE WIDTH=450 BORDER=0 CELLPADDING=0 CELLSPACING=0 id=news>
<tr >
<td width=113>
<p align=right><b>photo to be sent: </b>
</td>
<td width=289>
<p><input type=file name="$file" size=30></p>
</td>
</tr>
<tr><td><b>Description : </b>
</td>
<td ><input type="text" name="$desc" size="40" maxlength="80" >
</td>
</tr>
</TABLE>
</CENTER>
<DIV ALIGN=CENTER>
<P STYLE="margin-bottom: 0in"><INPUT TYPE=SUBMIT NAME="submit" VALUE="Upload File"></P>
</DIV>
</FORM>

[Upload Script]
<?
{
copy("$file", "$file_name");
}
$File = "programs.txt";
$Page = "index.php";
$filename = "programs.txt";
$fd = fopen( $filename, "r" );
$current = fread( $fd, filesize( $filename ) );
fclose( $fd );
$upload = "<br><font size='1' color='#000000' class='s3' face='Verdana'><a href="'$file_name'>$file_name</a> : $desc</font>";
$UFile = fopen("$page","w+");
fputs($UFile,$upload);
fclose($UFile);
?>


If you can help it would be much appreciated...
Thanks

~PeeKay Team

Posted: Mon Apr 14, 2003 3:49 pm
by bionicdonkey
maybe if you told us what the problem is we could narrow it down at bit

Posted: Mon Apr 14, 2003 3:51 pm
by volka
because otherwise the answer is just http://www.php.net/manual/en/features.file-upload.php ;)

another quick answer

Posted: Mon Apr 14, 2003 4:37 pm
by phpScott

Code: Select all

<input type=file name="$file" size=30>
is wrong as far as I know get rid of the $ in both of your input types

phpScott

Posted: Mon Apr 14, 2003 5:05 pm
by knightmayor
bionicdonkey wrote:maybe if you told us what the problem is we could narrow it down at bit
I get an error on this line
"$upload = "<br><font size='1' color='#000000' class='s3' face='Verdana'><a href="'$file_name'>$file_name</a> : $desc</font>"; "
I got rid of the $'s like you said to in the form and I still get the error..

Posted: Mon Apr 14, 2003 5:17 pm
by m3mn0n
Espcape your quotes.

Code: Select all

$upload = "
<br><font size=''1'' color=''#000000'' class=''s3'' face=''Verdana''>
<a href=''$file_name''>$file_name</a> : $desc</font>
";

Posted: Tue Apr 15, 2003 4:13 am
by twigletmac
What exactly is the error?

Mac