Uploading Multiple Files
PHP File Uploader allows you to select multiple files and upload multiple files at once.
1. Adding Uploader into PHP page and setting MultipleFilesUpload property to true.
//Step 1: Register Uploader component to your page
<?php
require_once
"phpuploader/include_phpuploader.php"
?>
<html>
<body>
<form id=
"form1"
method=
"POST"
>
<?php
//Step 2: Create Uploader object.
$uploader
=
new
PhpUploader();
//Step 3: Set a unique name to Uploader
$uploader
->Name=
"myuploader"
;
//Step 4: Enable Multiple Files Upload.
$uploader
->MultipleFilesUpload=true;
//Step 5: Render Uploader
$uploader->Render();
?>
</form>
</body>
</html>
2. Retrieving all uploaded files.
<?php
//Gets the file GUID list based on uploader name
$fileguidlist
=@
$_POST
[
"myuploader"
];
if
(
$fileguidlist
)
{
$guidlist
=split(
"/"
,
$fileguidlist
);
foreach
(
$guidlist
as
$fileguid
)
{
//get the uploaded file based on GUID
$mvcfile
=
$uploader
->GetUploadedFile(
$fileguid
);
if
(
$mvcfile
)
{
//Gets the name of the file.
echo
(
$mvcfile
->FileName);
//Gets the temp file path.
echo
(
$mvcfile
->FilePath);
//Gets the size of the file.
echo
(
$mvcfile
->
FileSize
);
//Copys the uploaded file to a new location.
$mvcfile
->CopyTo(
"/uploads"
);
//Moves the uploaded file to a new location.
$mvcfile
->MoveTo(
"/uploads"
);
//Deletes this instance.
$mvcfile
->
Delete
();
}
}
}
?>