Welcome Guest, Not a member yet? Register   Sign In
file upload controller
#1

[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" />
#2

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

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

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

change to

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

[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
#6

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

do

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

[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
#8

[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
#9

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

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




Theme © iAndrew 2016 - Forum software by © MyBB