Welcome Guest, Not a member yet? Register   Sign In
Problem with uploading file
#1

[eluser]Mohammed Zayan[/eluser]
I use this code in the view file
Code:
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<?php
$id = $competition_id;
echo form_open_multipart('site/add_user_competition');
if($id == 2){
  echo form_label('High quality', 'video_url');
  $data = array(
   'name'  => 'video_url',
   'id'    => 'video_url',
   'size'  => 40,
   'value' => ''
  );
  echo form_input($data);
  echo "<br />";
}
echo form_label('Select file to upload', 'user_file');
echo form_upload('userfile');
echo form_hidden('competition_id', $id);
echo form_submit('submit', ' upload file ');
echo form_close();
?&gt;

and this is add_user_competition function
Code:
function add_user_competition(){
   $config['upload_path'] = './uploads/';
   if($this->input->post('competition_id') == 2){
      $config['allowed_types'] = 'flv';
      $config['max_size']      = 153600;
   }else{
      $config['allowed_types'] = 'mp3';
      $config['max_size']      = 51200;
   }
   $this->load->library('upload', $config);
   if($this->upload->do_upload()){
      $data = $this->upload->data();
      $FileName =  $data['file_name'];
      $file_link = 'uploads/' . $FileName;
      $file_url = $this->input->post('video_url');
      $user_id = $this->session->userdata('user_id');
      $query = $this->site_model->add_competition_file($file_link, $file_url, $user_id);
      if($query){
         redirect('site/home');
      }
   }else{
      $data['message'] = $this->upload->display_errors();
      $this->load->view('test', $data);
   }
}

And when I select a file to upload I have this error {You did not select a file to upload.}
#2

[eluser]john_j[/eluser]
I don't think that $data['file_name']; is the variable that has the upload file name. do a print_r($_POST) in your controller method to see where the file name is stored.
#3

[eluser]Mohammed Zayan[/eluser]
There is no file uploaded
this error appear from this part of code
Code:
}else{
      $data['message'] = $this->upload->display_errors();
      $this->load->view('test', $data);
   }
#4

[eluser]Mohammed Zayan[/eluser]
I have solve this problem before
by change the name to userfile in this part
Code:
echo form_upload('userfile');
and it works
but now it doesn't work
What is the problem???
#5

[eluser]Mohammed Zayan[/eluser]
any one know what is the problem? and what's the solution?
#6

[eluser]Mohammed Zayan[/eluser]
I want a solution from the experts.
Is there one of them!!
#7

[eluser]Mohammed Zayan[/eluser]
Is there a solution to this problem?
#8

[eluser]Aken[/eluser]
Could be a few things. Try viewing the contents of $_FILES and see if there are any errors that help you figure out the issue.
#9

[eluser]Mohammed Zayan[/eluser]
Code:
print_r($_FILES); die();
Gives my
Array ()
#10

[eluser]Professor Doidão[/eluser]
I had this problem too

in $this->upload->do_upload()

you have that write so

$this->upload->do_upload('name_input_file)

I made and made the Upload

without name_input_file the CI
unknow what field it have get




Theme © iAndrew 2016 - Forum software by © MyBB