Upload в един файл :)

Teodotko

Registered
Значи трябва ми upload.php . Да качва файлове ( без ограничения ) в папка ../files/ .
 
Код:
 <html xmlns="http://www.w3.org/1999/xhtml">

<head>
<title>:: badc0de Upload Script</title>
<style>
body {
background-color: #999;
color: #CC0000;
}
#txt-input {
border: 1px solid #000;
background-color: #C0C0C0;
}

#submit {
border: 1px solid #000;
background-color: #C0C0C0;
}
</style>
</head>
<body>
<?php

// --- Vars --- //

$upl_path = "./"; // Change this to the directory you wish the uploaded file(s) to be placed in.

if (isset($_POST["bc_upload"])) {

$files = $_FILES['file'];

foreach ($files['name'] as $idx=>$file)
{

$file_name = $files['name'][$idx];
$file_name = strtolower($file_name);
$file_name = preg_replace('/[^a-z0-9_.]/i', '', $file_name);
$file_size= intval($files['size'][$idx]);
$tmp_file = $files['tmp_name'][$idx];

$copy = copy($tmp_file,$upl_path.$file_name);

if($copy) { echo ("Files uploaded successfully!<br />\n"); }
if(!$copy && $file_name != '') { echo ("<b>An error occoured while uploading the files!<br />\n"); }

} // end foreach

echo ("<a href='". $_SERVER["PHP_SELF"] ."'>Continue...</a>");

} // end if (isset($_POST["bc_upload"])) {

if (!isset($_POST["bc_upload"])) {

echo ("<form action='". $_SERVER["PHP_SELF"] ."' method='post' enctype='multipart/form-data'>\n");
echo ("<b>Files To Be Uploaded:</b>\n");
echo ("<br />\n");
echo ("<input name='file[]' type='file' id='txt-input' />\n");
echo ("<br />\n");
echo ("<input name='file[]' type='file' id='txt-input' />\n");
echo ("<br />\n");
echo ("<input name='file[]' type='file' id='txt-input' />\n");
echo ("<br />\n");
echo ("<input name='file[]' type='file' id='txt-input' />\n");
echo ("<br />\n");
echo ("<input name='file[]' type='file' id='txt-input' />\n");
echo ("<br /><br />\n");
echo ("<input name='bc_upload' type='submit' value='Upload' id='submit' />\n");
echo ("</form>\n");

}

?>
</body>
</html>
 

Back
Горе