Forum Moderators: coopster
You might find this thread useful:
[webmasterworld.com...]
In particular msg #29 by Birdman.
dc
// Where the file is going to be placed
$target_path = "uploads/";
/* Add the original filename to our target path. Result is "uploads/filename.extension" */
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
// This is how we will get the temporary file...
$_FILES['uploadedfile']['tmp_name'];
$target_path = "uploads/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
} else{
echo "<!-- error-->";
}
?>
<html>
<head>
<title>Uploader</title>
</head>
<body>
<form enctype="multipart/form-data" action="" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>
</body>
</html>
make a folder name call "uploads"
chmod 777 or 707
save this file name call upload.php for example
<html>
<head>
<title>Uploader</title>
</head>
<body>
<form enctype="multipart/form-data" action="" method="POST">
<p align="center">
<input type="hidden" name="MAX_FILE_SIZE" value="" />
Choose File you need to upload from your PC:</p>
<p align="center">
<input name="uploadedfile" type="file" /><br>
<br />
<input type="submit" value="Upload File" />
</p>
</form>
<p align="center">
<?php
// Where the file is going to be placed
$target_path = "uploads/";
/* Add the original filename to our target path. Result is "uploads/filename.extension" */
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
// This is how we will get the temporary file...
$_FILES['uploadedfile']['tmp_name'];
$target_path = "uploads/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "File ". basename( $_FILES['uploadedfile']['name']). "Your file is Uploaded" ;
} else{
echo "<!-- error-->";
}
?>
</p>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html><head>
<link rel="shortcut icon" href="http://www.example.co.uk/images/favicon2.bmp">
<!--StartFragment -->
<title>200m Peanut</title>
<link href="Style.css" type="text/css" rel="stylesheet" />
<style type="text/css">
<!--
.style44 {
font-family: "Arial Narrow";
font-weight: bold;
color: #000000;
font-size: 16px;
}
.style45 {
font-family: "Arial Narrow";
font-size: 14px;
}
.style46 {font-size: 16px}
-->
</style>
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" link="#000000" vlink="#000000" alink="#000000" >
<div align="center" class="style44"> </div>
<p align="center" class="style45 style46"><strong>Send us a Graphic</strong>
<p align="center" class="style45">Got a graphic your especially proud of? Want to show your artistic design handywork to the example Team then look no further
<p align="center" class="style45">Just use the form below and your fantastic graphic will come directly to me.
<p align="center"><center><FORM action= http://example.co.uk/cgi-sys/FormMail.cgi method=post>
<div align="center">
<INPUT type=hidden value= admin@example.co.uk name=recipient>
<INPUT type=hidden value="Upload" name=subject>
<INPUT type=hidden value="name,email," name=required>
<INPUT type=hidden value=http://www.example.co.uk/index.php?go=Confirmation4 name=redirect>
<form method="post" action="photoupload.asp" name="submit" enctype="multipart/form-data">
<div align="center">
<p align="center">Name:
<input type="text" name="name">
</p>
<div align="center">Email:
<input type="text" name="email">
</div>
<p>
<form enctype="multipart/form-data" action="" method="POST">
<p><form enctype="multipart/form-data" action="" method="POST">
<p align="center">
<input type="hidden" name="MAX_FILE_SIZE" value="" />
Choose file you need to upload from your PC:</p>
<p align="center">
<input name="uploadedfile" type="file" /><br>
<br />
<input type="submit" value="Upload File" />
</p>
</form>
<p align="center">
<?php
// Where the file is going to be placed
$target_path = "uploads/";
/* Add the original filename to our target path. Result is "uploads/filename.extension" */
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
// This is how we will get the temporary file...
$_FILES['uploadedfile']['tmp_name'];
$target_path = "uploads/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "File ". basename( $_FILES['uploadedfile']['name']). "Your file is Uploaded" ;
} else{
echo "<!-- error-->";
}
?></p>
<p align="center">Coding if it’s a grapic:</span><br>
<textarea cols=25 rows=6 name="comments">Put the coding in here for a graphic. The graphic will be uploaded to our server </textarea>
</p>
<p align="center">Thankyou for your contribution.
<p align="center"><input type="reset" value="Clear">
<input type="submit" value="Upload File" />
</form></center>
<br>
<br>
</p>
</div>
</form>
<br />
</div>
<p align="center"></form>
</center>
</body>
</html>
</p>
</body>
</html>
</p>
</body>
</html>
</p>
<p> </p>
</body></html>
[edited by: jatar_k at 6:15 pm (utc) on Feb. 13, 2006]
[edit reason] examplified url [/edit]