PHP upload to FTP from file contents

Basaa

While you can upload files to an FTP server with ftp_put, that would need a file that you want to upload. What if the contents of a file are inside a MySQL field?

How can I upload a file that lives in a MySQL BLOB field to an FTP server (so upload a file from a string containing file data instead of a file path)? I'm looking for a native solution, not a workaround. This because writing the data to a file, uploading the file, and deleting a file would take too long.

Edit to clarify the OP's question: I have a string variable that I want to upload to an FTP server. The quick and dirty way is to create a physical temporary file from my string variable, upload that file to the FTP server, and then delete the temporary file. But is there a way to upload the string variable directly to the FTP server without having to create a temporary file from it?

Basaa

Okay, I found a solution.

$fileContent = 'My file contents here';
$contentstream = fopen('data://text/plain,' . $fileContent, 'r');
ftp_fput($myConnection, '/path/to/my/folder/file.txt', $contentStream, FTP_BINARY);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

upload file via ftp from ftp in PHP

From Dev

php file_get_contents FTP

From Dev

Loading file contents from FTP to ListBox

From Dev

PHP file_put_contents() save file from ftp directory to local directory

From Dev

Upload single image file to FTP using PHP

From Dev

Upload a .zip file to FTP and unzip it using PHP

From Dev

Upload a file to a server using FTP using php

From Dev

Upload single image file to FTP using PHP

From Dev

Upload a .zip file to FTP and unzip it using PHP

From Dev

How to Download file from one FTP and then Upload file to different FTP?

From Dev

Ajax upload a file from browser to FTP server

From Dev

Upload a file to an FTP server from a string or stream

From Dev

Download file from url and upload into ftp

From Dev

FTP File upload from Memory in C

From Dev

Ajax upload a file from browser to FTP server

From Dev

FTP File upload from Memory in C

From Dev

PHP get_file_contents with FTP server file

From Dev

Put a file on FTP site with contents from string variable (no local file)

From Dev

cURL : Display/get text file contents using FTP with PHP

From Dev

Dynamic Upload file to FTP

From Dev

Upload text file to Google uploads via PHP FTP PUT

From Dev

Upload a ZIP file and UNZIP ftp folder via PHP

From Dev

How to upload a sqlite db file to ftp server from android program

From Dev

FTP file upload using perl from local system

From Dev

Phonegap:Get the file from sdcard and upload it to the FTP Server in android

From Dev

How to upload a file from the command line with FTP or SSH?

From Dev

How to upload a sqlite db file to ftp server from android program

From Dev

Reading all file contents from a directory - php

From Dev

PowerShell upload file to ftp will upload file twice

Related Related

  1. 1

    upload file via ftp from ftp in PHP

  2. 2

    php file_get_contents FTP

  3. 3

    Loading file contents from FTP to ListBox

  4. 4

    PHP file_put_contents() save file from ftp directory to local directory

  5. 5

    Upload single image file to FTP using PHP

  6. 6

    Upload a .zip file to FTP and unzip it using PHP

  7. 7

    Upload a file to a server using FTP using php

  8. 8

    Upload single image file to FTP using PHP

  9. 9

    Upload a .zip file to FTP and unzip it using PHP

  10. 10

    How to Download file from one FTP and then Upload file to different FTP?

  11. 11

    Ajax upload a file from browser to FTP server

  12. 12

    Upload a file to an FTP server from a string or stream

  13. 13

    Download file from url and upload into ftp

  14. 14

    FTP File upload from Memory in C

  15. 15

    Ajax upload a file from browser to FTP server

  16. 16

    FTP File upload from Memory in C

  17. 17

    PHP get_file_contents with FTP server file

  18. 18

    Put a file on FTP site with contents from string variable (no local file)

  19. 19

    cURL : Display/get text file contents using FTP with PHP

  20. 20

    Dynamic Upload file to FTP

  21. 21

    Upload text file to Google uploads via PHP FTP PUT

  22. 22

    Upload a ZIP file and UNZIP ftp folder via PHP

  23. 23

    How to upload a sqlite db file to ftp server from android program

  24. 24

    FTP file upload using perl from local system

  25. 25

    Phonegap:Get the file from sdcard and upload it to the FTP Server in android

  26. 26

    How to upload a file from the command line with FTP or SSH?

  27. 27

    How to upload a sqlite db file to ftp server from android program

  28. 28

    Reading all file contents from a directory - php

  29. 29

    PowerShell upload file to ftp will upload file twice

HotTag

Archive