显示图像

时间:2016-06-15 07:48:43

标签: codeigniter

我正在尝试实现图片上传器,但是当我想显示图片时,我收到了这个错误。此外,我可以看到它不会将其上传到指定的文件夹中。我做错了什么?

move_uploaded_file(/Applications/XAMPP/xamppfiles/htdocs/Codeigniter/uploads/41d3f16b60a5e8.jpg): failed to open stream: Permission denied

Message: move_uploaded_file(): Unable to move \'/Applications/XAMPP/xamppfiles/temp/phpAFbOft\' to \'/Applications/XAMPP/xamppfiles/htdocs/Codeigniter/uploads/41d3f16b60a5e8.jpg\'

file_get_contents(/Applications/XAMPP/xamppfiles/htdocs/Codeigniter/uploads/41d3f16b60a5e8.jpg): failed to open stream: No such file or directory

2 个答案:

答案 0 :(得分:0)

你能说出你想做什么吗?

move_upload_file接受两个参数。而你只是传递它的文件路径。

看看这个

http://php.net/manual/en/function.move-uploaded-file.php

答案 1 :(得分:0)

让这个简单

if(isset($_FILES['myfile']['name']))
{ 
    $file = $_FILES['myfile']['name'];
    $location  = 'img/upload/';
    if(move_uploaded_file($_FILES['myfile']['tmp_name'],$location.$file))
    {
        $ImagePath = $location.$file;
        $imagedata = file_get_contents($ImagePath);
        $ret       = base64_encode($imagedata);
    }
}

希望这对你有用