使用PHP编辑文件图像上载

时间:2013-11-21 11:06:46

标签: php database upload

我一直遇到文件上传问题。在这个网站上的帮助后,我设法成功地将文件上传到数据库,并可以将它们拉回来显示图像。我的评估部分是我需要能够编辑我的照片选择(通过选择不同的图像,也许保持一个或两个相同)然后用户可以提交他们可能希望进行的任何更改。所以在一个名为'edit.php'的单独文件中,我预先填充了在db中输入的所有其他数据(这适用于很好)我的代码看起来像:

<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 = 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!";  
}

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

0 个答案:

没有答案