![]() |
file upload - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: file upload (/showthread.php?tid=8032) |
file upload - El Forum - 05-02-2008 [eluser]bramb79[/eluser] Hi, I'm trying to use the upload library included in CI. It seems there is a problem with my system's configuration though: when my own script didn't work, I tried to copy the example from the User Guide to see if that would work. There just doesn't seem to be anything stored in $this->upload->data()... Are there any settings that I might have overlooked? Could there be another problem? thanks! file upload - El Forum - 05-02-2008 [eluser]gtech[/eluser] one thing that caught me out when I first used upload is that the form has to have a field called "userfile" which is used to store the path of the file to upload. if this is not in the post data the do_upload function will not work. also ensure you have created the uploads directory, at the root of your install [edit] If all else fails you can look at the upload library in system\libraries\Upload.php and look at the do_upload function.. you could put some debug (either log_debug or echo) just to see how far it is getting. I tend to but debug in the codeigniter code if I am not sure how a function is working (not forgetting to make a backup copy). [/edit] file upload - El Forum - 05-02-2008 [eluser]bramb79[/eluser] Thanks for your answer. I copied the example from the user guide, there is a 'userfile' field in my form. I am not even uploading the file actually. I seems like there is no data passed at all, because the $this->upload->data() is not filled... This is my code: Code: <?php echo form_open_multipart('upload/do_upload'); ?> Code: function do_upload() file upload - El Forum - 05-02-2008 [eluser]gtech[/eluser] ok you need to make a call to $this->upload->do_upload() otherwise it will not even attempt to upload the file. look at the upload library in system\libraries\Upload.php and the do_upload function.. you will see that is the function that uploads the file and sets the data. try using the documentions upload controller without cutting corners Code: <?php file upload - El Forum - 05-02-2008 [eluser]bramb79[/eluser] I commented that out, because I wanted to test if there was any data at all. Still when I add it again it gives the following error: 'The upload path does not appear to be valid.' I think this might be because some of the elements in the data array (like filename, etc) are empty? file upload - El Forum - 05-02-2008 [eluser]bramb79[/eluser] Hmm ok.. It seems to work now I have actually created the ./uploads folder. Strange but true ![]() Thanks! file upload - El Forum - 05-02-2008 [eluser]gtech[/eluser] yep the line you commented out is the function that gets the file from the clients computer and sets the data variable.. so thats why you had no data ![]() anyway glad you figured it all out, I had some fun and games with the upload when I first used it. |