FTP transfer script with user prompt for remote destination

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Bryan Baer Bryan Baer 5 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #38190
    Profile photo of Bryan Baer
    Bryan Baer
    Participant

    I have a script I wrote to transfer files from a Windows 10 tablet to a remote for server working as intended. New wrinkle is that the user wants the ability to either select an existing directory on the remote server or enter the name of a new directory to be created. I'm really stuck. Can anyone point me in the right direction? My Google foo is failing me.

    Thanks!

    #38191
    Profile photo of Anthony Stringer
    Anthony Stringer
    Participant

    Are you sure you're using ftp and not smb/cifs? What is your current script?

    #38192
    Profile photo of Bryan Baer
    Bryan Baer
    Participant

    Yep, positive it's FTP:

    #Specify the directory where all files that we want to upload
    $source="C:\Users\$Env:username\Pictures\Camera Roll\"
    $destination = "ftp:[email protected]//media/data/photos/"

    $webclient = New-Object System.Net.WebClient

    $files = Get-ChildItem $source

    foreach ($file in $files)
    {
    Write-Host "Uploading $file..."
    $webclient.UploadFile("$destination/$file", $file.FullName)
    Remove-Item $source/$file
    }

    $webclient.Dispose()

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.