2

I am trying to move file outside Codeigniter path like "/home/uploads" using move_uploaded_file or copy but both method doesn't work!

I uploaded the files by using Grocery Crud library & tried to move file using callback_after_upload.

in Grocery Crud Controller:

 $crud->callback_after_upload(array($this, 'upload'));

and in the callback function:

function upload($uploader_response,$field_info, $files_to_upload){
ini_set("display_errors",1);
$baseURl = site_url();
            $upload_config['upload_path'] = ''; 
$file_uploaded = $field_info->upload_path.'/'.$uploader_response[0]->name; 
copy($file_uploaded, "/home/uploads/");

any help please!

Abu Yousef
  • 570
  • 3
  • 21
  • Unless you're running your script from the root directory of the server (you're not...), `home/uploads` and `/home/uploads` are two completely different directories. You should check the exact path and file permissions for that path. – jeroen Apr 27 '16 at 12:37
  • Thanks @jeroen edited, I am using ( /home/uploads/ ) in my script, just , how to check if I have the permission to upload in that path, noting that the file "uploads" have 777 permission – Abu Yousef Apr 27 '16 at 12:41

1 Answers1

1

I think you need to include the filename in the destination

copy($file_uploaded, "/home/uploads/".$uploader_response[0]->name);

move_uploaded_file() is probably more appropriate as it won't leave a file in the upload folder like copy() does. Again, include the file's name in the destination.

DFriend
  • 8,869
  • 1
  • 13
  • 26