首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >上传失败,没有错误

上传失败,没有错误
EN

Stack Overflow用户
提问于 2015-05-13 04:49:32
回答 2查看 362关注 0票数 2

我想用注册表格上传一个文件。我使用了Codeigniter的File_Upload库。但该文件不会上载到目标,也不会出现错误。这只是我代码的一部分(它们都非常庞大)

控制器(seeker_register.php):

代码语言:javascript
复制
public function submit(){
...
$this->load->model('mseeker_register');
$user_id = $this->mseeker_register->register($data);

视图(vseeker_register.php):

代码语言:javascript
复制
$attr = array("class" => 'form-horizontal seeker_register','id' => 'form-seeker-register');
echo form_open_multipart('seeker_register/submit',$attr);
...
<div class="col-sm-6 col-sm-offset-3">
<input name="Aks" type="file" class="fileinput" accept=".jpg, .jpeg">
</div>

模型(mseeker_register.php):

代码语言:javascript
复制
...
// Prepare Aks
$config = array(
    'upload_path' => './img/users',
    'allowed_types' => 'jpg|jpeg|JPG|JPEG',
    'max_size' => '200',
    'max_width' => '1024',
    'max_height' => '768');

$this->upload->initialize($config);
$this->upload->do_upload('Aks');

$this->upload->display_errors();
exit();
...

这是$ This ->上载->data()输出:

代码语言:javascript
复制
Array
(
    [file_name] => Clipboard-2.jpg
    [file_type] => image/jpeg
    [file_path] => D:/khayyamkar.ir/www/img/users/
    [full_path] => D:/khayyamkar.ir/www/img/users/Clipboard-2.jpg
    [raw_name] => Clipboard-2
    [orig_name] => 
    [client_name] => Clipboard-2.jpg
    [file_ext] => .jpg
    [file_size] => 156.42
    [is_image] => 1
    [image_width] => 
    [image_height] => 
    [image_type] => 
    [image_size_str] => 
)
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-05-13 06:06:17

当我扫描您的代码时,我意识到您没有办法查看错误。

要查看错误是什么/是否需要使用var_dump()print_r() php方法来查看错误是什么。

例如:

代码语言:javascript
复制
var_dump($this->upload->display_errors());

在当前代码中,需要更改:

代码语言:javascript
复制
$this->upload->display_errors();
exit();

至:

代码语言:javascript
复制
var_dump($this->upload->display_errors());
exit();

您需要首先识别错误才能找到解决方案。

:)

票数 3
EN

Stack Overflow用户

发布于 2015-05-13 05:26:03

代码语言:javascript
复制
public function register() {

    $config = array(
        'upload_path' => './img/user',
        'allowed_types' => 'jpg|jpeg|JPG|JPEG|png',
        'max_size' => '200',
        'max_width' => '1024',
        'max_height' => '768');

    $this->upload->initialize($config);

    // you need to make sure that the upload path is existing
    // and also check the folder permission to be rwxr-xr-x
    // if you installed in a server where permission is required
    // for you to create image inside the folder

    // create a folder img/user in the root directory of the project
    // where application or system located

    // this will check 
    if ($this->upload->do_upload('Aks')) {
        echo 'success'; die;
    } else {
        var_dump($this->upload->display_errors());die;
    }


}

请参阅文件上传CodeIgniter

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30205916

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档