Upload Script Code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
knightmayor
Forum Newbie
Posts: 2
Joined: Mon Apr 14, 2003 2:58 pm

Upload Script Code

Post 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
bionicdonkey
Forum Contributor
Posts: 132
Joined: Fri Jan 31, 2003 2:28 am
Location: Sydney, Australia
Contact:

Post by bionicdonkey »

maybe if you told us what the problem is we could narrow it down at bit
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

because otherwise the answer is just http://www.php.net/manual/en/features.file-upload.php ;)
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

another quick answer

Post 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
knightmayor
Forum Newbie
Posts: 2
Joined: Mon Apr 14, 2003 2:58 pm

Post 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..
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post 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>
";
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

What exactly is the error?

Mac
Post Reply