uploading

KH85

Senior member
Jun 24, 2002
673
0
0
i wish to make a small site where people can upload there "work" to it. so they can get it later does anyone know the code for this

Either HTML or PHP

Thanks in advance

KHGamez
 

KH85

Senior member
Jun 24, 2002
673
0
0
to be able to upload files. and to create DIR's and be able to view the files that have been uploaded.

Thanks for the reply
 

Beau

Lifer
Jun 25, 2001
17,730
0
76
www.beauscott.com
Haven't checked it, but something similar to this:

<?PHP

var $UploadTargetLocation = "C:\\My Location\\"; // best to use an absolute location, including the last slash
// var $UploadTargetLocation = realpath("my relative path"); // uncomment and use this for relative paths, though its buggy for some virtual hosts.

if(strtolower($_REQUEST("action")) == "upload"){
if($_FILES["file1"]["name"] != "" && $_FILES["file1"]["name"] != NULL){

$oFile = $_FILES["file1"];

copy($oFile["tmp_name"], $UploadTargetLocation . $oFile["name"])) or die("Failed to copy the file");

header("Location: " . $_SERVER("PHP_SELF") . "?action=success");

}
}

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form enctype="multipart/form-data" action="<?PHP echo $_SERVER['PHP_SELF']?>" method="post">
<input type="file" name="file1"/><input type="submit" name="action" value="Upload"/>
</form>
</body>
</html>