Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $conn_id = ftp_connect('***');
- $login_result = ftp_login($conn_id, '***','***');
- if( $login_result) echo 'connected';
- $save = "FTP://temp/". $FileName;
- imagepng($this->Picture, $save);
- /*if (ftp_put($conn_id,$save,$save, FTP_ASCII))
- echo "successfully uploaded n";
- else
- echo "There was a problem while uploading n";
- */
- ob_start();
- imagepng($this->Picture);
- $image = ob_get_clean();
- $stream = stream_context_create(array('ftp' => array('overwrite' => true)));
- file_put_contents("ftp://user:pass@host/folder/".$FileName, $image, 0, $stream);
- <?
- //Configuration
- $ftp_server = "ftpaddress";
- $ftp_user = "username";
- $ftp_pass = "password";
- // set up a connection or die
- $conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");
- //trying to connect with login details
- if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
- echo "Connected! ";
- } else {
- echo "Couldn't connect!";
- }
- //You can change it with the file name, this is for if you're upload using form.
- $myName = $_POST['name']; //This will copy the text into a variable
- $myFile = $_FILES['file_name']; // This will make an array out of the file information that was stored.
- ?>
- <?PHP
- $destination_path = "dest/path/";
- //your desired path for uploading)
- $destination_file = $destination_path."img.jpg";
- //This will create a full path with the file on the end for you to use, I like splitting the variables like this in case I need to use on on their own or if I'm dynamically creating new folders.
- $file = $myFile['tmp_name'];
- //Converts the array into a new string containing the path name on the server where your file is.
- $upload = ftp_put($conn_id, $destination_file, $file, FTP_BINARY);// upload the file
- if (!$upload) {// check upload status
- echo "FTP upload of $destination_file has failed!";
- } else {
- echo "Uploaded $file to $conn_id as $destination_file";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement