CodeIgniter Forums
Could not move file to - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Could not move file to (/showthread.php?tid=75487)



Could not move file to - JerryCode - 02-11-2020

PHP Code:
public function index(){
    
$file= new \CodeIgniter\Files\File('https://www.***.com/***.jpg');
    
$type $file->getExtension();
    
//success:jpg
    
$newName $file->getRandomName();
    
$file->move(WRITEPATH.'uploads',$newName);
    
//error:
    //CodeIgniter\Files\Exceptions\FileException
    //Could not move file ***.jpg to D:\\WWW\ci\writable\uploads/ ()




error:
CodeIgniter\Files\Exceptions\FileException
Could not move file ***.jpg to D:\\WWW\ci\writable\uploads/ ()


RE: Could not move file to - dave friend - 02-11-2020

Does the destination exist?
Do the permissions of the destination allow for file write operations?


RE: Could not move file to - JerryCode - 02-11-2020

(02-11-2020, 11:19 AM)dave friend Wrote: Does the destination exist?
Do the permissions of the destination allow for file write operations?

Yes,Is locally developed


RE: Could not move file to - littlej - 02-11-2020

Hello JerryCode !

Using localhost doesn't mean you have the correct permissions to write in the folders. You should verify ;-)

And you could also try to create a random file to see if you there is no permissions issues with CI: https://www.php.net/manual/fr/function.file-put-contents.php