使用PHP编辑文件图像上载

使用PHP编辑文件图像上载,php,database,upload,Php,Database,Upload,我在上传文件方面遇到了一些问题。在这个网站上得到帮助后,我成功地将文件上传到数据库,并可以将它们拉回来显示图像。我的部分评估是,我需要能够编辑我的照片选择(比如选择一个不同的图像,可能保留一个或两个相同的图像)然后,用户可以提交他们可能希望进行的任何更改。因此,在一个名为“edit.php”的单独文件中,我预先填充了数据库中输入的所有其他数据(这很好),我的代码如下所示: <label for ="file">Filename:</label> <?php ec

我在上传文件方面遇到了一些问题。在这个网站上得到帮助后,我成功地将文件上传到数据库,并可以将它们拉回来显示图像。我的部分评估是,我需要能够编辑我的照片选择(比如选择一个不同的图像,可能保留一个或两个相同的图像)然后,用户可以提交他们可能希望进行的任何更改。因此,在一个名为“edit.php”的单独文件中,我预先填充了数据库中输入的所有其他数据(这很好),我的代码如下所示:

<label for ="file">Filename:</label>
  <?php echo "<img src='upload/".$_FILES['filename']."' />"; ?>
  <input type="file" name="file[]" id="file" >
  <?php echo "<img src='upload/".$_FILES['filename']."' />"; ?>
  <input type="file" name="file[]" id="file" >
  <?php echo "<img src='upload/".$_FILES['filename']."' />"; ?>
  <input type="file" name="file[]" id="file" >
文件名:
PHP:

$name=strtolower($name);
$allowedExts=数组(“gif”、“jpeg”、“jpg”、“png”);
$temp=分解(“.”,$name);
$extension=end($temp);
if(在数组中($extension,$allowedExts))
{
如果($_文件['file']['size'][$f]<2000000)
{
$uniqid=uniqid();
移动上传的文件($\\\\\\\\\\\\\\\\\\\\\\\\\\\\\$f],“上传/”$uniqid.“$扩展名);
mysql_查询(“插入到VehicleImages(vehicleid,文件名)值(“.last_id.”、“.uniqid.”、“.extension.”);
}
其他的
{
echo“文件大小变大!”;
}
}
其他的
{
echo“不支持图像,请重试!”;
}

如果您有任何想法/帮助或有用的网站,我将不胜感激。因为我无法研究有关该主题的任何信息。

您有什么问题?你在哪里?我想问你想要实现什么?什么是$f?你们真的很抱歉,伙计们。我已经成功上传了图片,所以当我点击这个文件时,我想给用户一个选项,要么保留他们最初上传的文件,要么浏览一个新的文件
    $name = strtolower($name);

$allowedExts = array("gif", "jpeg", "jpg", "png");
$temp = explode(".", $name);
$extension = end($temp);

if(in_array($extension, $allowedExts))
{
    if($_FILES['file']['size'][$f] < 2000000)
    {
        $uniqid = uniqid();

        move_uploaded_file($_FILES["file"]["tmp_name"][$f], "upload/" . $uniqid  . "." . $extension);


        mysql_query("INSERT INTO vehiclesimages (vehicleid, filename) VALUES (".$last_id.", '".$uniqid .".".$extension."')");

    }
    else
    {
        echo "File size to big!";   
    }
}
else
{
    echo "Image not supported, please try again!";  
}