Jump to content

Uploading an image sent as byte array to FTP


MattLav
 Share

Recommended Posts

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

Link to comment
Share on other sites

Can I ask why you are converting an "image" ( a picture/photo/piece of art that is a jpg,tiff,mpg, etc. file) ) to some  kind of array in order to upload it using an ftp process?  I would think that you would do that to the image once you got it uploaded where you could write a script to do what it is you are doing.

Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • 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.