Codeigniter多图上传错误信息
我的多图像上传有问题。
代码
function tester($yourUniqueId){
$this->load->library('upload');
for($i=0; $i<count($_FILES); $i++)
{
$_FILES['userfile']['name'] = $_FILES['filename']['name'][$i];
$_FILES['userfile']['type'] = $_FILES['filename']['type'][$i];
$_FILES['userfile']['tmp_name'] = $_FILES['filename']['tmp_name'][$i];
$_FILES['userfile']['error'] = $_FILES['filename']['error'][$i];
$_FILES['userfile']['size'] = $_FILES['filename']['size'][$i];
$path = './uploads/' . $yourUniqueId;
mkdir($path);
$config['file_name'] = "kep_" . $i;
$config['upload_path'] = $path;
$config['allowed_types'] = 'jpg|jpeg|png';
$config['max_size'] = '0';
$config['overwrite'] = FALSE;
$this->upload->initialize($config);
if($this->upload->do_upload())
{
$error += 0;
}else{
$error += 1;
}
}
if($error > 0){
return FALSE;
}else{
return TRUE;
}
}
有点奇怪,因为它返回 false,我给它一个回声,
if($error > 0){
echo 'Something went wrong'; //just for a test
return FALSE;
难道它不应该显示回声吗?
我无法让它发挥作用。
代码有什么问题吗?
有人可以给我提示吗? 我在任何地方都看不到它
I have a problem with my multi image upload.
The code
function tester($yourUniqueId){
$this->load->library('upload');
for($i=0; $i<count($_FILES); $i++)
{
$_FILES['userfile']['name'] = $_FILES['filename']['name'][$i];
$_FILES['userfile']['type'] = $_FILES['filename']['type'][$i];
$_FILES['userfile']['tmp_name'] = $_FILES['filename']['tmp_name'][$i];
$_FILES['userfile']['error'] = $_FILES['filename']['error'][$i];
$_FILES['userfile']['size'] = $_FILES['filename']['size'][$i];
$path = './uploads/' . $yourUniqueId;
mkdir($path);
$config['file_name'] = "kep_" . $i;
$config['upload_path'] = $path;
$config['allowed_types'] = 'jpg|jpeg|png';
$config['max_size'] = '0';
$config['overwrite'] = FALSE;
$this->upload->initialize($config);
if($this->upload->do_upload())
{
$error += 0;
}else{
$error += 1;
}
}
if($error > 0){
return FALSE;
}else{
return TRUE;
}
}
Its a bit strange, because, it it returns false, and i give it an echo
if($error > 0){
echo 'Something went wrong'; //just for a test
return FALSE;
Doesnt it sopose to show the echo?
I cant make it work.
Is there something worng with the code?
Could please someone give me a hint?
I cant see it anywhere
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试替换这个:
与这个:
这应该告诉你出了什么问题。您可能还想包装 mkdir() 函数,以防目录确实存在(我不知道 PHP 如何处理它,否则可能会提前返回):
Try replacing this:
With this:
That should tell you what went wrong. You also might want to wrap the mkdir() function just in case the directory does exist (I don't know how PHP handles it otherwise--might be returning early):