Hello,
1. Create one form like:
<form enctype="multipart/form-data" action="WHERE_YOU_POST" method="POST"> // define the method
<input name="upload" type="file" />
//define the name and type
<input type="submit" value="upload" /> // submit button
</form>
2. Create the "WHERE YOU POST" step by step,
$today = date("His"); // date - if you use this to rename the uploads
// define what you allow
// like gif images
$types = array(
"image/png",
"image/jpeg",
"image/gif",
"image/pjpeg",
"image/bmp",
"image/vnd.wap.wbmp",
"video/3gpp",
"audio/midi",
"audio/wav",
"audio/x-wav",
"audio/amr",
"audio/mp4",
"audio/mpeg",
"audio/3gpp",
"audio/mp3",
"image/x-bmp",
"application/x-smaf",
"video/avi",
"video/mpeg",
"video/mp4",
"audio/x-ms-wma",
"application/java",
"application/java-archive",
"text/vnd.sun.j2me.app-descriptor",
"application/vnd.symbian.install");
// check if the upload match with allowed extension
if (in_array($_FILES['upload']['type'], $types))
{
if ($_FILES['upload']['size'] < $size) // here you allow one value for each upload
{
$tmp_name = $_FILES['upload']['tmp_name']; // temp folder - here server put the upload short time (lol)
$new_name = $today .'_'. $_FILES['upload']['name']; // rename the upload if you have identic name
$target_path = "up/"; // path to final upload folder
$target_path = str_replace("..", "", str_replace("\.", "", str_replace("//", "/", $target_path))); // replace some values like spaces
$clean_name = ereg_replace("[^a-z0-9._]", "", str_replace(" ", "_", str_replace("%20", " ", strtolower($new_name) ) ) ); // make all names lowercase
move_uploaded_file($tmp_name,$target_path . $clean_name); // and the final and most important thing. move from temp in UP folder.[/b]
Bookmarks