Getting file path of uploaded image in FTP server

Hi all!

I’m currently working on a project where I upload files in my ftp server. I’m stuck in the part where I have to retrieve the file path of the uploaded file.

Here is my code for calling my ftp function

void Start () {
        /* Create Object Instance */
        ftp ftpClient = new ftp(ftpURL, username, password);

        /* Upload a File */
        ftpClient.uploadimage("test_photos/test_image.jpg", Application.dataPath + "/StreamingAssets/test.jpg");
    }

and here is the code i have for uploading

/* Upload Image */
    public void uploadimage(string remoteFile, string localFile)
    {

        try
        {
            FtpWebRequest ftpRequest = (FtpWebRequest)WebRequest.Create(host + "/" + remoteFile);
            ftpRequest.UseBinary = true;
            ftpRequest.UsePassive = true;
            ftpRequest.KeepAlive = true;
            ftpRequest.Method = WebRequestMethods.Ftp.UploadFile;
            ftpRequest.Credentials = new NetworkCredential(user, pass);
            byte[] fileData = File.ReadAllBytes(localFile);

            ftpRequest.ContentLength = fileData.Length;
            Stream reqStream = ftpRequest.GetRequestStream();
            reqStream.Write(fileData, 0, fileData.Length);
            reqStream.Close();
            ftpRequest = null;

            Debug.Log("Image uploaded.");

        }
        catch (Exception ex) { Debug.Log(ex.ToString()); }
        return;

    }

I can upload image to my FTP server without any problem. However, I want to get the link of that uploaded file. Any help would be greatly appreciated. Thanks.

What link? You uploaded it with the remote filepath “test_photos/test_image.jpg” and it says it uses host + “/” + remoteFile, so as far as the FTP filepath goes, you already have it. I’m not quite sure what you’re looking for.

If, by chance, you want a web address for that file, FTP and HTTP are different protocols. The specific FTP account that you’re accessing could be in the public_html directory on the server somewhere (assuming an apache server here), but more than likely it’s not. It doesn’t even have to be pointing at a web server- it could be a different PC on the same network. That means the file likely isn’t actually accessible using the HTTP protocol from browsers, and there’s no web-address to retrieve it. Even if it were in the public_html directory, the account could be rooted in any sub-directory at all, so the only way to figure out the specific path is to know exactly how the server and the FTP account are configured.