我正在尝试上传的文件与邮递员,但得到了错误的信息:You did not select a file to upload.我不知道是什么原因,但也试图找到方法。
看看Postman的gif:

看看php代码:
public function upload_post()
{
$this->load->helper(array('form', 'url'));
$config = array(
'upload_path' => "./uploads/",
'allowed_types' => "gif|jpg|png|jpeg|pdf",
'overwrite' => TRUE,
'max_size' => "2048000",
'max_height' => "768",
'max_width' => "1024"
);
$this->load->library('upload',$config);
if($this->upload->do_upload())
{
$data = array('upload_data' => $this->upload->data());
$this->set_response($data, REST_Controller::HTTP_CREATED);
}
else
{
$error = array('error' => $this->upload->display_errors());
$this->response($error, REST_Controller::HTTP_BAD_REQUEST);
}
}看看html:
<?php echo $error;?>
<?php echo form_open_multipart('api/example/upload');?>
<input type="file" name="userfile" size="20" />
<br /><br />
<input type="submit" value="upload" />
</form>用浏览器上传文件没问题!

两个代码就可以了!浏览器上传没有问题!但是不能用邮递员上传!
已经解决了,原来是不加$this->upload->do_upload('file')和关键file的邮递员。

发布于 2018-01-27 22:42:24
你能把你的表格代码放进去吗?我想你忘了加上enctype='multipart/form-data'
https://stackoverflow.com/questions/48476631
复制相似问题