我在更改上传文件名时遇到问题。我希望de filename为1.pat用于第一次上传2.pat用于第二次等等。我怎样才能做到这一点? ('plaatje'表示荷兰语中的图像)
<?php
function patuploader()
{
echo '
<div id="uploadForm">
<form action="'.$_SERVER['PHP_SELF'].'" method="post" enctype="multipart/form-data">
<label for="plaatje">Plaatje:</label>
<input type="file" name="plaatje" id="plaatje" /><br />
<label for="submit"></label>
<input type="submit" name="submit" id="submit" value="Verstuur bestand!" /><br />
</form>
</div>
';
if(isset($_POST['submit']) && isset($_FILES['plaatje']) && $_FILES['plaatje'] ['type']=="application/octet-stream"){
move_uploaded_file($_FILES['plaatje']['tmp_name'], './upload/'.time().''.$_FILES['plaatje']['name']);
}elseif(isset($_FILES['plaatje']) && $_FILES['plaatje']['type']!="application/octet-stream"){
echo '<span id="warning">it's not possible to upload this file. you can only upload .pat files.</span>';
}
# Lees de inhoud van de map uit
$bestandenRij = scandir('./upload');
$bestandenRij = array_reverse($bestandenRij);
foreach($bestandenRij as $bestand){
# Toon alle bestanden anders dan . (localdir) en .. (magic escalator)
if($bestand != '.' && $bestand != '..'){
echo "\t<img src=\"./upload/".$bestand."\" width=\"20\"/><br />\r\n";
}
}
}
?>