小编Tab*_*Man的帖子

CodeIgniter:如何从文件夹中删除上传的图像

我想删除不仅在数据库中,而且在文件夹中的图像.

这是我的数据库表:

group_id
group_name
group_descrtion
group_picture
Run Code Online (Sandbox Code Playgroud)

这是我的控制器:

    public function delete_group()
    {
            $group_id = $this->input->post('group_id');
            $group_picture = $this->input->post('group_picture');

            $this->group_model->delete_group($group_id, $group_picture);
            redirect('product_group');
    }
Run Code Online (Sandbox Code Playgroud)

这是我的模特:

        function delete_group($group_id, $group_picture)
        {
                $this->db->where('group_id', $group_id);

                unlink(base_url("uploads/".$group_picture));

                $this->db->delete('product_group', array('group_id' => $group_id));
        }
Run Code Online (Sandbox Code Playgroud)

这是我的看法:

 <?=form_open_multipart('product_group/delete_group');?>

   <input type="hidden" class="form-control" placeholder="Group ID" name="group_id">
   <input type="text" class="form-control" placeholder="Group ID" name="group_picture">

  <div class="modal-footer">
     <button data-dismiss="modal" class="btn btn-default" type="button">Cancel</button>
     <button class="btn btn-success" type="submit">Submit</button>
   </div>
 </form>
Run Code Online (Sandbox Code Playgroud)

我成功删除了数据库中的数据,但是文件夹中的图像也没有被删除.

谢谢你的帮助 :)

php codeigniter image

4
推荐指数
1
解决办法
3万
查看次数

PHP:从哈希解密密码

所以,我使用以下代码成功地将密码加密为密码哈希:

class PassHash 
{

    // blowfish
    private static $algo = '$2a';
    // cost parameter
    private static $cost = '$10';

    // mainly for internal use
    public static function unique_salt() 
    {
        return substr(sha1(mt_rand()), 0, 22);
    }

    // this will be used to generate a hash
    public static function hash($password) 
    {

        return crypt($password, self::$algo .
                self::$cost .
                '$' . self::unique_salt());
    }

    // this will be used to compare a password against a hash
    public static function check_password($hash, $password) 
    {
        $full_salt = substr($hash, 0, …
Run Code Online (Sandbox Code Playgroud)

php encryption hash

2
推荐指数
1
解决办法
1849
查看次数

标签 统计

php ×2

codeigniter ×1

encryption ×1

hash ×1

image ×1