Chi Kien Uong
Geranienstraße 30
71034 Böblingen
Deutschland / Germany
|
If you are not registered or logged in, you may still use these forums but with limited features.
Show recent topics
|
|
|
Author |
Message |
03/09/2004 23:23:21
|
Anonymous
|
i just added a php upload script to my site and it will not allow me to overwite a file that already exists and i need to be able to do that. can someone help please? the code is below.
______________________________
<?
session_start();
//include('UserModel.inc');
//file_upload.php
$archive_dir = "/home/mlbtborg/public_html/upload";
if($action == 'upload') upload_file();
else upload_form();
function upload_form() {
global $PHP_SELF;
?>
<html>
<head>
<title>MLBTB Soccer Club</title>
<LINK href="../Local%20Settings/Temporary%20Internet%20Files/Content.IE5/CPUJKXM3/style/style.css" rel=stylesheet type=text/css>
</head>
<body bgcolor="#FFFFFF" background="../Local%20Settings/Temporary%20Internet%20Files/Content.IE5/CPUJKXM3/images/main_bg.jpg" leftmargin="0" topmargin="0" rightmargin="0" marginwidth="0" marginheight="0">
<table border="0" cellpadding="0" cellspacing="0" width=800 height=100%>
<tr> <td width="100" align="middle" bgcolor=#6D5143 height=100% > </td>
<td valign=top width=700>
<table border="0" cellpadding="3" cellspacing="3" width=100%>
<tr><td align=right><a href = "../Local%20Settings/Temporary%20Internet%20Files/Content.IE5/CPUJKXM3/index.php">Home</a> | <a href="../Local%20Settings/Temporary%20Internet%20Files/Content.IE5/CPUJKXM3/index.php?logout=true">Logout</a></td></tr>
</table>
<table border="0" cellpadding="3" cellspacing="3" width=450 align=center>
<tr><td colspan=2 align=center class=tdclassb>Image Upload </td></tr>
<FORM METHOD="POST" ENCTYPE="MULTIPART/FORM-DATA" ACTION="upload.php">
<table border="0" cellpadding="5" cellspacing="1" width=450 align=center bgcolor=#DCCFC9>
<tr><td bgcolor=white>
<table border="0" cellpadding="5" cellspacing="1" width=450 align=center>
<tr>
<td width="450" height="21" align="left" valign="middle" class=tdclass>
<INPUT TYPE="HIDDEN" NAME="action" VALUE="upload">
Upload file
<INPUT TYPE="FILE" NAME="userfile">
<INPUT TYPE="SUBMIT" class ="button" NAME="SUBMIT" VALUE="upload">
</td>
</tr>
<tr>
<td width="450" height="21" align="right" valign="top" tdclass>
<a href = "../Local%20Settings/Temporary%20Internet%20Files/Content.IE5/CPUJKXM3/AddNews.php">Next</a>
</td>
</tr>
</table>
</td></tr>
</table>
</td></tr>
</table>
</FORM>
</html>
<?
}
function upload_file() {
global $userfile, $userfile_name, $userfile_size,
$userfile_type, $archive_dir, $WINDIR;
if(isset($WINDIR)) $userfile = str_replace("\\\\","\\", $userfile);
$filename = basename($userfile_name);
if($userfile_size <= 0) die ("$filename is empty.");
if(!@copy($userfile, "$archive_dir/$filename"))
die("Can't copy $userfile_name to $filename.");
if(!isset($WINDIR) && !@unlink($userfile))
die ("Can't delete the file $userfile_name.");
// header ("Location: AddNews.php?FN=$filename");
echo "$filename has been successfully uploaded.<BR>";
echo "Filesize: " . number_format($userfile_size) . "<BR>";
echo "Filetype: $userfile_type<BR>";
}
?>
|
|
|
|
|
|
Based on the open source JForum
|