CodeIgniter Forums
file upload controller - 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 controller (/showthread.php?tid=27515)

Pages: 1 2


file upload controller - El Forum - 02-13-2010

[eluser]KrizzAngel[/eluser]
i cant get it to work Sad pls help.. here's my controller:
it keeps on saying "You did not select a file to upload."

Quote:
class admin extends Controller {

function admin(){
parent::Controller();
$this->load->helper('form');
}

function upload() {
$baseLoc= base_url();
$config['upload_path'] = $baseLoc."assets/Lessons/";
$config['allowed_types'] = 'swf|flv';
$chap = $this->input->post('chapnum');
$less= $this->input->post('lessnum');
$config['file_name'] = "lesson_".$chap;

$this->load->library('upload', $config);
if ( ! $this->upload->do_upload('file'))
{
echo $this->upload->display_errors();
}
else
{
echo $this->upload->data();
}
}
}

and my view page:

Quote:<? echo form_open_multipart('admin/upload'); ?>
<input type="hidden" name="chapnum" value="<? echo $chapnumber; ?>" />
<input type="hidden" name="lessnum" value="<? echo $lessNum; ?>" />
<input type="file" name="vid" /><br />
<input type="submit" value="Next" />



file upload controller - El Forum - 02-13-2010

[eluser]Jan_1[/eluser]
Formular is sending to a function called "addLesson" in admin controller.... ?!


file upload controller - El Forum - 02-13-2010

[eluser]KrizzAngel[/eluser]
ooppsss.. typo error.. there changed it already.. the upload function still dont work.. Sad
cant upload my swf file arghh


file upload controller - El Forum - 02-13-2010

[eluser]flaky[/eluser]
Code:
if ( ! $this->upload->do_upload('file'))

change to

Code:
if ( ! $this->upload->do_upload('vid'))



file upload controller - El Forum - 02-13-2010

[eluser]KrizzAngel[/eluser]
oh XD damn forgot bout the field name.. oh another problem.. "The upload path does not appear to be valid." any tips on how can i specify absolute path, coz the destination folder is located outside system folder


file upload controller - El Forum - 02-13-2010

[eluser]flaky[/eluser]
instead of
Code:
$config[‘upload_path’] = $baseLoc.“assets/Lessons/”;

do

Code:
$config[‘upload_path’] = “./assets/Lessons/”;



file upload controller - El Forum - 02-13-2010

[eluser]KrizzAngel[/eluser]
"./assets/Lessons/" on what directory would this go??
my DIR looks like this:

www
-codeigniter
-assets
| -Lessons <-- i want to put the files here
-System
-Application
and so on


file upload controller - El Forum - 02-14-2010

[eluser]Zorancho[/eluser]
'./assets/Lessons/' is the absolute path, it will upload the files exactly where you want them. Without trying and testing the code, you wont learn much Smile


file upload controller - El Forum - 02-14-2010

[eluser]VinceVe[/eluser]
Btw check if your map has enough rights to upload into it Wink


file upload controller - El Forum - 02-14-2010

[eluser]KrizzAngel[/eluser]
oh my bad... tnx