• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to integrate upload file with my form

#1
[eluser]cybersven[/eluser]
Hi,

I'm new to CI and I would like to integrate in an existing form, the upload file.
Before that I've tested the upload from the documentation and it works,
now I've downloaded a complete example form and it works well, so I'm trying to integrate the upload without success, could you help me ?

Here is the controller : https://docs.google.com/document/d/1JtQu...sp=sharing

#2
[eluser]noideawhattotypehere[/eluser]
Have a form_open_multipart() instead of form_open() in your view, then
Code:
<input type="file" name="userfile" size="20"/>

will be your input file field, place anywhere you want in your view, then after initialization of your upload library call
Code:
$this->upload->do_upload()
If it fails it returns false so you can do some error logging etc. Simple as that, i wont write everything for you as your document is so terrible to work with. (especially that 2342342343 line function)

#3
[eluser]cybersven[/eluser]
So if I understand do_upload() is a specific function from CI.
Here is the file
https://docs.google.com/file/d/0B4WpmjlD...sp=sharing
the googledoc has broken the code :/

I've added
Code:
'image_path' => $this->upload->do_upload(),
but I don't see how can I check the function with '$this->form_validation->set_rules' , actually the form is OK and in the database I got a 0 in the image_path...

#4
[eluser]CroNiX[/eluser]
This should help: http://ellislab.com/codeigniter/user-gui...ading.html

$this->upload->do_upload() returns TRUE/FALSE, so that's why you're getting that for the filename.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.