lazzard / php-ftp-client

:package: Provides helper classes and methods to manage FTP files in an OOP way.
MIT License
90 stars 18 forks source link

How to upload $_File Data or base64 file #46

Closed patelsumit5192 closed 10 months ago

patelsumit5192 commented 11 months ago

Hello sir, I have uploaded a simple method it's working fine but I want to upload a file using the $_File variable using your library. if any method are present then guide me or provided link.

AmraniCh commented 11 months ago

Hey.

Of course you can upload a file using $_FILE, just use the library API method upload() and specify the local file path that is inside the $_FILE super global, like so:

$uploaddir = '/var/www/uploads/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);

if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
    $client->upload($uploadfile, 'path/to/remote/file');
}

If you need any help let me know!