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

[eluser]Mohammed Zayan[/eluser]
In the Upload library it has a default value
Code:
public function do_upload($field = 'userfile')
I'll change it in my form and pass it to do_upload function for try
#12

[eluser]Mohammed Zayan[/eluser]
It still doesn't work
#13

[eluser]Mohammed Zayan[/eluser]
In this problem I want to upload audios & videos files as here
Code:
if($this->input->post('competition_id') == 2){
      $config['allowed_types'] = 'flv';
      $config['max_size']      = 153600;
   }else{
      $config['allowed_types'] = 'mp3';
      $config['max_size']      = 51200;
   }
I make this to know what $_FILES array contan
Code:
echo "<pre>"; print_r($_FILES); echo "</pre>"; die();
When I select a video file or an audio file
I have this
Code:
Array
(
)
but when I select an image I have this
Code:
Array
(
    [userfile] => Array
        (
            [name] => 174509_510945018_2402858_n.jpg
            [type] => image/jpeg
            [tmp_name] => D:\xampp\tmp\phpFD38.tmp
            [error] => 0
            [size] => 14239
        )

)
so the problem with audio & video.
How can I fix it??
#14

[eluser]Mohammed Zayan[/eluser]
I want a solution for this problem
can anyone help me?
#15

[eluser]LuckyFella73[/eluser]
You said you get data if you select an image.

Try to set this (just for debugging!):
Code:
$config['allowed_types'] = '*'; // all filetypes allowed

for both cases (flv , mp3)

If the upload works now it's probably a mime-type issue.
#16

[eluser]Mohammed Zayan[/eluser]
I try it and I have the same result
You did not select a file to upload.
#17

[eluser]LuckyFella73[/eluser]
Can you please post your actual controller code including
the print_r line?
#18

[eluser]Mohammed Zayan[/eluser]
This is my view code
Code:
&lt;meta http-equiv="content-type" content="text/html; charset=utf-8" /&gt;
&lt;?php
$id = $competition_id;
echo form_open_multipart('site/add_user_competition');
if($id == 2){
  echo form_label('Video URL : ', 'video_url');
  $data = array(
   'name'  => 'video_url',
   'id'    => 'video_url',
   'size'  => 40,
   'value' => ''
  );
  echo form_input($data);
  echo "<br />";
}
echo form_label('Choose File : ', 'user_file');
echo form_upload('selected_file');
echo form_hidden('competition_id', $id);
echo form_submit('submit', ' Upload! ');
echo form_close();
?&gt;

and this is the function add_user_competition from site controller
Code:
function add_user_competition(){
  echo "<pre>"; print_r($_FILES); echo "</pre>"; die();
  //config settings
  $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);
  //print_r($_FILES); die();
  //$file = $this->input->post('selected_file');
  if($this->upload->do_upload('selected_file')){
  
   $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);
  }
  
  // print_r($_FILES); die();
  // $this->load->library('Uploader');
  // $this->uploader->uploadFile();  
}
#19

[eluser]Mohammed Zayan[/eluser]
Guys,
I solve it.
The problem was in php.ini file
Code:
// it was
post_max_size = 8M

// I make it
post_max_size = 128M

Thank you guys.




Theme © iAndrew 2016 - Forum software by © MyBB