Php 使用codeigniter上传多幅图像

Php 使用codeigniter上传多幅图像,php,codeigniter,file-upload,codeigniter-2,Php,Codeigniter,File Upload,Codeigniter 2,我有一个网页,将插入用户名,ID和用户必须能够上传多达10个图像 im的主要问题是使用codeigniter上传多个图像 有人能建议我如何传递每个图像的每个图像路径吗 将单个图像发送到阵列,以便我可以将其传递到数据库 如果用户选择上传少于10张图片,比如2张或5张 那我怎么能忽略一个错误,说一个文件没有被删除 selected和jst仅传递已上载的图像 <form method="post" action="uploader/go" enctype="multipart/form-data

我有一个网页,将插入用户名,ID和用户必须能够上传多达10个图像

im的主要问题是使用codeigniter上传多个图像

  • 有人能建议我如何传递每个图像的每个图像路径吗 将单个图像发送到阵列,以便我可以将其传递到数据库

  • 如果用户选择上传少于10张图片,比如2张或5张 那我怎么能忽略一个错误,说一个文件没有被删除 selected和jst仅传递已上载的图像

    <form method="post" action="uploader/go" enctype="multipart/form-data">
    <input name="username" type="text" /><br />
    <input name="nid" type="text" /><br />
    <input type="file" name="image1" /><br />
    <input type="file" name="image2" /><br />
    <input type="file" name="image3" /><br />
    <input type="file" name="image4" /><br />
    <input type="file" name="image5" /><br />
    <input type="file" name="image6" /><br />
    <input type="file" name="image7" /><br />
    <input type="file" name="image8" /><br />
    <input type="file" name="image9" /><br />
    <input type="file" name="image10" /><br />
    <input type="submit" name="go" value="Upload!!!" />
    </form>
    

    任何帮助都将不胜感激。

    将输入名称更改为:

    <input type="file" name="image[1]" /><br />
    <input type="file" name="image[2]" /><br />
    <input type="file" name="image[3]" /><br />
    

    将输入名称更改为:

    <input type="file" name="image[1]" /><br />
    <input type="file" name="image[2]" /><br />
    <input type="file" name="image[3]" /><br />
    

    酷。。。谢谢,但是如果没有选择图像怎么办?如何跳过该错误?您甚至可以为每个文件字段设置

    ,以便phpcool自动生成ID。。。谢谢,但是如果没有选择图像怎么办?如何跳过该错误?您甚至可以为每个文件字段设置

    ,以便php自动生成ID
    foreach($this->upload->data('image') as $image) {
       passItToTheDatabase(); // your custom function
    
    }