• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can't upload file

#1
[eluser]ArifBD[/eluser]
I am a newbie in CodeIgniter.. i am trying to upload file .. I am following "CodeIgniter User Guide Version 2.1.3: CodeIgniter Home › User Guide Home › File Uploading Class" example for file uploading.. but every time it returns "The upload path does not appear to be valid".... I am using windows 7 operating system and folder permission is set to everyone full permission.... I have also tried from the example of "CodeIgniter from Scratch- Day 9 - File Uploading and Image Manipulation - Nettuts+" and having the same problem... Please need urgent support

#2
[eluser]noslen1[/eluser]
Can you post your controller function code ?

Have you created you upload folder in your installation ? CI won't do it for you.

What is your $config['upload_path'] ?


#3
[eluser]ArifBD[/eluser]
i have simply use the code from the following page.... and yes i have created a folder name "uploads" in root directory and as it was not working i also created same folder in the application directory.
http://ellislab.com/codeigniter/user-gui...ading.html

Controller:
upload.php
Code:
<?php

class Upload extends CI_Controller {

function __construct()
{
  parent::__construct();
  $this->load->helper(array('form', 'url'));
                //$this->document_path= realpath(APPPATH.'../uploads');
}

function index()
{
  $this->load->view('upload_form', array('error' => ' ' ));
                
}

function do_upload()
{
  //$config['upload_path'] = $this->document_path;
                $config['upload_path'] = './uploads/';
  $config['allowed_types'] = 'gif|jpg|png';
  $config['max_size'] = '100';
  $config['max_width']  = '1024';
  $config['max_height']  = '768';

  $this->load->library('upload', $config);
                
  if ( ! $this->upload->do_upload())
  {
   $error = array('error' => $this->upload->display_errors());
                        $data = array('upload_data' => $this->upload->data());
   $this->load->view('upload_form', $error,$data);
  }
  else
  {
   $data = array('upload_data' => $this->upload->data());

   $this->load->view('upload_success', $data);
  }
}
}
?>

#4
[eluser]j0se[/eluser]
Hi.

webserver can write in ./uploads/ ?? Check folder permisions. The folder is in root where are aplication,
system folders???

#5
[eluser]ArifBD[/eluser]
"D:\xampp\htdocs\upload\uploads" and also "D:\xampp\htdocs\upload\application\uploads" are the physical folder location, but according to the code it should have been the first one. as it was not working i created the second folder... and yes i have already check the folder permission as i mentioned earlier.

#6
[eluser]j0se[/eluser]
Change the name of your folder...
"D:\xampp\htdocs\upload\uploads" to
"D:\xampp\htdocs\uploads\uploads"

config_path is set to "./uploads/" Smile

#7
[eluser]ArifBD[/eluser]
it doesn't mater if it is upload or uploads or any xyz at that position .... u can get the full code at
http://ellislab.com/codeigniter/user-gui...ading.html

#8
[eluser]noslen1[/eluser]
Is your Upload library autoloaded in your /config/autoload.php file ?
If so, try initialize your config with :
Code:
$this->upload->initialize($config);

instead of :
Code:
$this->load->library('upload', $config);

#9
[eluser]j0se[/eluser]
You dont understand me (my english is bad).
I try again, when you configure the settings you say that the folder will be "./uploads/" and in your webroot
( D:\xampp\htdocs\ ) the folder is upload .... I think that you rename the folder o change the config_path.

Not¿?

#10
[eluser]noslen1[/eluser]
I think /upload/ (without S) is his root directory where CI is installed, and /uploads/ his upload directory where to put upload files


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.