Welcome Guest, Not a member yet? Register   Sign In
uploading files outside the root folder
#1

[eluser]ebuoe[/eluser]
hello everyone ... below is a sample of code i use for uploading images to a gallery in my application ... just for improved secirity i decided that i should upload the files to another folder outside my root directory ... anoda folder in my www .... i specified the full file path to the directory where it should uploaad to but that is where the error started .... it did not work ... would appreciate it if sum1 helped me with this


Code:
if($this->form_validation->run()==FALSE)
         {
          $this->load->view("c_user/gallery_drawing",$data);
         }
         else
         {
  
  
         /*the directory for uploading the drawing file*/
              $dir = "./gallery/safe/";
//(for uploading out side the root folder i specified this path http://folder_outside_root_folder/gallery/safe)
    
        
              /*preparing the config settings for upload */
              
        /*renamin the file with random encryptions*/      
    
        $rand_num2=mt_rand(1,1000000);
        $rand_num3=sha1(mt_rand(1,1000000));
        $new_name=$rand_num2.$user_name.$rand_num3;
        
              $config['file_name'] = $new_name; // the new file name the image should have
              $config['upload_path'] = $dir; // the directory the image should go to,already specified
              $config['allowed_types'] = 'gif|jpg|png'; // the file types that are allowed
              $config['max_size']    = '10000'; //the maximum image size
              $config['max_width']  = '0'; //the maximum image width
              $config['max_height']  = '0'; // the maximum image height

              $this->load->library('upload', $config); // retrieving the upload library with the specified settings

              /*using the do upload settings upload the file if it fails stop upload and show errors*/
          if(! $this->upload->do_upload("drawing_file"))
          {
          
          $data["msg"] = $this->upload->display_errors();;
          $this->load->view("c_user/i_craft_user_gallery_drawing",$data);
          }
#2

[eluser]InsiteFX[/eluser]
You can try this, but you may also need to give it the full url path.
Code:
$dir = "../gallery/safe/";

Also make sure you have your permissions set right for the folder!

InsiteFX
#3

[eluser]ebuoe[/eluser]
i use $dir="../gallery/safe/"; for uploading within the website folder it works perfectly well ... but what i want to do now is to upload outside the root folder and it is not working
#4

[eluser]InsiteFX[/eluser]
Directory handling is very easy for each directoy you want to move up ../ so

Try this, just keep adding ../ until you get where you want to go.
Code:
$dir = "../../gallery/safe/";

InsiteFX
#5

[eluser]ebuoe[/eluser]
thanks a lot
#6

[eluser]InsiteFX[/eluser]
Your very Welcome!




Theme © iAndrew 2016 - Forum software by © MyBB