我試圖在上傳過程中重命名一個圖像我知道我遇到把函數rand()和end()但我只是不知道把它放在哪裏是我的代碼如下在上傳過程中重命名一個圖像在php
的PHP/HTML部分
if (isset($_POST['uploadimage'])) {
list($typed) = $_FILES['images']['type'];
if(!ereg("image",$typed)){
echo "<div class='msg1'>File is not an image or field is empty</div>";
}else{
$pixsname = $_FILES['images']['name'];
while(list($key,$value) = each($_FILES['images']['name'])){
if(!empty($value)) {
$pixsname = $value;
$add = "./img/venues/$pixsname";
copy($_FILES['images']['tmp_name'][$key], $add);
chmod("$add",0777);
}
$image = new Image();
$image->load("$add");
$image->resize(652,300);
$image->save("$add");
}
echo "<div class='msg1'>Image profile has been updated</div>";
}
}
form method="post" enctype="multipart/form-data" id="loginform" >
<input type="hidden" name="MAX_FILE_SIZE" value="200000000">
<input type="file" name="images[]" id="fileField" class="field_ss"/>
<?php echo $pix; ?>
<input type="submit" name="uploadimage" value="Upload Image"/>
</form>
請閱讀http://php.net/manual/en/features.file-upload.post-method.php – Mir 2014-09-03 09:29:20