Welcome Guest, Not a member yet? Register   Sign In
File Uploader W/Drag N Drop
#1

[eluser]Unknown[/eluser]
Hello everyone, this is my first topic here in the CI Foruns but I have been a faithfull member for months eheh.

I have a small issue that I cant get through. I have made a file uploader website (for images, if you want to see it just go to http://dragon-scale-studios.com/imaga/) and it is working well (just using regular file dialog). Now I want to make Drag N Drop funcionality but I have encountered a problem that I can't solve.

Code:
<div id="actionbar">
          <div class="hiddenfile">
          &lt;input type="file" id="file1" name="file1"&gt;
            </div>
            <div id="value"> <span id="valuex" name="valuex"> Choose one Image File to load or Drag N Drop here... </span> </div>
            &lt;input type="text" id="namefile" name="namefile" value=""&gt;
        </div>

This is the code that contains the area to drop. I was successful to retrieve the name of the file at the momment of the drag using an external class that I have found on the internet.

My question is: how can I attach the selected (drag n drop) file to the Input File?

Btw, my php code here:

Code:
public function do_upload()
{
  $config['upload_path'] = './uploads/';
  $config['allowed_types'] = 'gif|jpg|jpeg|png';
  $config['max_size'] = '10000';
  $config['max_width']  = '8192';
  $config['max_height']  = '8192';
  
  $exploded =  explode(".", $_POST['namefile']);
  $extension = "." . end ($exploded);
  
  $this->load->helper('string');
  $random_password = random_string('alnum', 5);
  $config['file_name'] = md5($random_password . $_POST['namefile']);

  $this->load->library('upload', $config);

  //error:
  if (!$this->upload->do_upload('valuex'))
  {
   $error = array('error' => $this->upload->display_errors());
  
   $data['page'] = "frontpage";
   $this->load->view('template', $data);
  } //sucess:
  else
  {  
   $originalLink = base_url() . "uploads/" . $config['file_name'] . $extension;
   $last = $this->session->userdata('uploaded');
   if($last != "")
   {
    $this->session->set_userdata('uploaded', $originalLink . "|" . $this->session->userdata('uploaded'));
   }
   else
   {
    $this->session->set_userdata('uploaded', $originalLink);
   }
  
   $data = array('upload_data' => $this->upload->data());

   $data['page'] = "image";
   $data['image'] = $config['file_name'] . $extension;
  
   redirect('main/image/' . $data['image'], $data);
  }
}

Thanks for your time. Smile
#2

[eluser]weboap[/eluser]
this may be out of the subject but i used this before

https://github.com/valums/file-uploader/issues/174


code at : https://gist.github.com/1254273

hope it help.




Theme © iAndrew 2016 - Forum software by © MyBB