在php中上传期间重命名图像

时间:2014-09-03 09:25:03

标签: php

我试图在上传过程中重命名图像我知道我遇到了放置函数rand()和end()但我只是不知道在哪里放它是我的代码在下面

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> 

1 个答案:

答案 0 :(得分:0)

替换

$pixsname = $value;

$pixsname = 'The_New_Name_Of_Your_Picture';
相关问题