Multiple Upload isnt working |
[eluser]flyenig[/eluser]
How can i make this code upload multiple photos? I atempted to try this but It did not work at all so I posted my orignial Code if you are wondering if i even tried to do this myself or not, can someone help me out? Thank you in advance. Here is the code The CONTROLLER Code: function upload() The MODEL Code: function newPhoto($stupdata) and the VIEW Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ?> Thank you
[eluser]Fabdrol[/eluser]
Well, first of all.. your 'userfile' POST data is an array, so your code should run it through some foreach or for loop somewhere. Something like "foreach($this->input->post('userfile') as $userfile) { $this->upload_pic($userfile); }" have fun! Fabian
[eluser]flyenig[/eluser]
ok that didnt work and i tried this and it didnt work either: Code: function upload_pic()
[eluser]Fabdrol[/eluser]
You're making one big mistake. See this line: Code: $arr = $_FILES['userfile']['tmp_name']; Code: $_FILES['userfile'] = array( see where you're going wrong? If you want to test the contents of $_FILES, try to 'print_r' it, like this: Code: public function upload_pic() { that way you can see how userfile is layed out. If you post the printout of that code here, I can help you along with some code examples.
[eluser]flyenig[/eluser]
Yeah i tried $_FILES['userfile']['name']; before and it didnt work so i put "tmp_name" to see if it worked but it didnt lol. But yea i see what you are saying and this is what came out from the "print_r" function: Code: Array
[eluser]Fabdrol[/eluser]
Yeah, thats it.. Listen, as you can see this array is a bit strangely formatted, so I'd rebuild that first if I were you. Example; Code: $file_array = $_FILES['userfile']; now you have a nicely formatted array you can loop through. Think you can take it from here? Have fun!
[eluser]flyenig[/eluser]
thank you for that, but im still having trouble looping through all the pictures and excuting the code. This is what ive done so far and it gives me multiple errors saying "you did not select a file to upload" Code: function upload_pic()
[eluser]asmedrano[/eluser]
I recently had to do something like that and I found this http://ellislab.com/forums/viewthread/80610/ extremely helpful
[eluser]Fabdrol[/eluser]
Hmg I don't know if you can pass the variable right into 'do_upload()'. Why don't you write a php native upload function? Personally, I find that the CI upload class doesn't really add anything to it beyond restricting your coding ;-)
[eluser]flyenig[/eluser]
ok ill try both of you guys methods and ill post back after. |
Welcome Guest, Not a member yet? Register Sign In |