move_uploaded_file
(string
Example:
<?php
if( isset($_POST['submit']) )
{
$uploads_dir = '/uploads';
foreach ($_FILES["fileToUpload"]["error"] as $key => $error)
{
if ($error == UPLOAD_ERR_OK)
{
$tmp_name = $_FILES["fileToUpload"]["tmp_name"][$key];
$name = $_FILES["fileToUpload"]["name"][$key];
move_uploaded_file($tmp_name, "$uploads_dir/$name");
}
}
}
else
{
echo "<br><br><br><center>";
echo '<form action="" method="post" enctype="multipart/form-data">';
echo 'Select file to upload:';
echo '<input type="file" name="fileToUpload" id="fileToUpload"><br><br><br>';
echo '<input type="submit" value="Upload" name="submit">';
echo '</form>';
echo "</center>";
}
?>
$filename
, string $destination
)Example:
<?php
if( isset($_POST['submit']) )
{
$uploads_dir = '/uploads';
foreach ($_FILES["fileToUpload"]["error"] as $key => $error)
{
if ($error == UPLOAD_ERR_OK)
{
$tmp_name = $_FILES["fileToUpload"]["tmp_name"][$key];
$name = $_FILES["fileToUpload"]["name"][$key];
move_uploaded_file($tmp_name, "$uploads_dir/$name");
}
}
}
else
{
echo "<br><br><br><center>";
echo '<form action="" method="post" enctype="multipart/form-data">';
echo 'Select file to upload:';
echo '<input type="file" name="fileToUpload" id="fileToUpload"><br><br><br>';
echo '<input type="submit" value="Upload" name="submit">';
echo '</form>';
echo "</center>";
}
?>
0 comments:
Post a Comment