Jump to content

MattLav

New Members
  • Posts

    1
  • Joined

  • Last visited

Posts posted by MattLav

  1. Hi all,

    I'm trying to upload an image to an FTP after sending it as a byte array. 

    I am sending the image from UE4 using REST:

    07GX8s3.png

    but I have no understanding of PHP so am struggling with processing the image to in-turn upload it.

    I have tried searching the forums and the results I have found seem to be defining the path to a local image and uploading that directly, but in this case I don't have a path to an image, just the byte array.
    Because I have such little understanding of PHP, i'm struggling to discover how to access the actual data being sent and therefore even debug if it is sent correctly.

     

    <?php
     $ftp_server="1.1.1.1";
     $ftp_user_name="username";
     $ftp_user_pass='password123';
     $remote_file = "/uploads/temp.jpg";
    
    //my attempt at converting the byte array to an image
     $binary=base64_decode($base);
    
     // set up basic connection
     $conn_id = ftp_connect($ftp_server);
    
     // login with username and password
     $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
     
    file_put_contents($filePath, $binary);
    
     // upload a file
     if (ftp_put($conn_id, $remote_file, $filePath, FTP_ASCII)) {
        echo "successfully uploaded $file\n";
        exit;
     } else {
        echo "There was a problem while uploading $fileName\n";
        exit;
        }
     // close the connection
     ftp_close($conn_id);
    ?>

     

    Any help would be much appreciated,

     

    Thanks,

     

    Matt

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.