[英]Uploading multiple files per field and storing in a db with codeigniter
I have a form which uploads multiple file fields into a db using codeigniter. 我有一个使用codeigniter将多个文件字段上传到数据库的表单。
I need to be able to upload multiple files for each field. 我需要能够为每个字段上传多个文件。 I understand that this could be achieved using some jquery magic, however, my problem is how do I intercept the multiple files and what is the best way to store them in my database?
我知道可以使用一些jquery魔术来实现,但是,我的问题是如何截取多个文件?将它们存储在数据库中的最佳方法是什么?
At the minute I just have one field which stores the file location/name, would I need to insert all the files as one long comma seperated string? 目前,我只有一个存储文件位置/名称的字段,我是否需要将所有文件作为一个长逗号分隔的字符串插入? If so, how do I then make use of that string for my view functions to show each file?
如果是这样,我该如何在我的视图函数中使用该字符串显示每个文件?
Sorry if the above doesn't make sense, I can explain in more detail or post my code if required. 抱歉,如果上述方法没有意义,我可以详细解释,或者在需要时发布我的代码。
Thanks for any help in advance 在此先感谢您的帮助
Dan 担
It pains me to say this, but the best method of uploading multiple files at once is to use a plugin like Uploadify . 这么说让我很痛苦,但是一次上传多个文件的最好方法是使用类似Uploadify的插件。
With regard to how you'd like to store it in the database...If you're allowing a single user to upload multiple files, I'd recommend having three tables: 关于您希望如何将其存储在数据库中...如果要允许单个用户上传多个文件,我建议您使用三个表:
Then when you store the files on your server, you can insert a new row into your "files" table. 然后,将文件存储在服务器上时,可以在“文件”表中插入新行。 Then when you delete files, be sure to remove the row in the files table and the association in the users_files table.
然后,当您删除文件时,请确保删除文件表中的行以及users_files表中的关联。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.