【问题标题】:PHP Remove File from Folder and DatabasePHP 从文件夹和数据库中删除文件
【发布时间】:2016-02-04 16:11:36
【问题描述】:

我正在尝试使用 php 取消链接功能从文件夹和数据库中删除图像并删除查询。这是我的代码,问题是我不会从文件夹中删除图像。请帮忙。

 $filetmp=$_FILES["images"]["tmp_name"];
      $filename=$_FILES["images"]["name"];
      $filetype=$_FILES["images"]["type"];
      $filepath= "photo2/".$filename;
      move_uploaded_file( $filetmp,$filepath);
      $data=array($page_id,$filepath);
     $add=add_data_event($data);
      foreach ($errors as $value)
         {
              echo $value;
         }           
        if(isset($_GET['id']))
            {
                $id=$_GET['id'];
                delete_event1($id);
                unlink("photo2/".$filename);
               header('location:hotel2_galery_event.php?page_id=2');

            }

HTML

<div class="form-group has-info">
<label>Event Related images</label>
<input type="file" name="images"><br>
</div>
<button type="submit" class="btn btn-primary">
<span>SUBMIT</span>
</button> 

【问题讨论】:

  • 你的文件夹有删除文件的权限吗?
  • 你应该会在错误日志中看到错误,我认为@sandeepsure 说得通
  • 文件夹权限问题.. 正如@sandeepsure所说
  • 也可能是错误的路径..
  • 尝试使用图像的完整路径,而不是显示的相对路径

标签: php html database image file


【解决方案1】:

看看这个,

http://www.codingcage.com/2014/12/delete-uploaded-files-from-folder-in-php.html

希望这会有所帮助。

苏海尔。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-04-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-13
    • 1970-01-01
    相关资源
    最近更新 更多