Jump to content
Sign in to follow this  
jim1

how to send files in a server?

Recommended Posts

jim1

couldnt find anything aout sending files so i ask u

i want to try to send a file to a server but have no idea where to start from, do i need to make a gui first?any simple examples? command syntax?

Share this post


Link to post
Share on other sites
linc

couldnt find anything aout sending files so i ask u

i want to try to send a file to a server but have no idea where to start from, do i need to make a gui first?any simple examples? command syntax?

If you want to send via FTP I have an example for you.

Func FTPimagesToServer(Const $scriptname, Const $templocation, ByRef $dir)
;$scriptname = name of scriptfile for ftp to use
;$templocation = where you want to create the temp files
;$dir = if you need a unique subdir for each file
    $FTPserver = "server.name"
    $FTPuser = "username"
    $strpas = "password"

    $ftpfile = FileOpen($scriptname, 10) 
    If $ftpfile = -1 Then
        MsgBox(0, "Error", "File Open Failure")
        Exit
    EndIf
    FileWrite($ftpfile, $FTPuser & @CRLF)
    FileWrite($ftpfile, $strpas & @CRLF)
    FileWrite($ftpfile, "binary" & @CRLF)
    FileWrite($ftpfile, "lcd " & Chr(34) & $templocation & $dir & Chr(34) & @CRLF)
    FileWrite($ftpfile, "cd " & Chr(34) & "path_on_server" & Chr(34) & @CRLF)
    FileWrite($ftpfile, "Mkd " & Chr(34) & $dir & Chr(34) & @CRLF)
    FileWrite($ftpfile, "cd " & Chr(34) & $dir & Chr(34) & @CRLF)
    FileWrite($ftpfile, "put " & Chr(34) & "filename.ext" & Chr(34) & @CRLF)
    FileWrite($ftpfile, "ascii" & @CRLF)
    FileWrite($ftpfile, "bye" & @CRLF)
    FileClose($ftpfile)
    $status = Run(@ComSpec & " /c ftp -s:" & $scriptname & " " & $FTPserver, $templocation, @SW_HIDE)

    If @error <> 0 Then
        MsgBox(0,"",$status & " Return from FTP" & "Error: " & @error)
    EndIf
EndFunc  ;==>_FTPimagesToServer

It is usually easier to make something better, than to invent it.

Share this post


Link to post
Share on other sites
jim1

thanks very much for the answer.

but i an bit new to ftp commands and i have questions

i have a script and i want when u press a button enter a server ftp and put a rar file with known name, i was using if case for the buttons can i add ftp commands there or i need func always?

$scriptname=(is the name of the file i want to send?

$templocation= u mean the server folder i want to copy file?

$dir =file is only one so it will not be needed

is there something more small and simple like connect server copy file and send in the folder u want? because it isnt so easy for me.

Share this post


Link to post
Share on other sites
linc

thanks very much for the answer.

but i an bit new to ftp commands and i have questions

i have a script and i want when u press a button enter a server ftp and put a rar file with known name, i was using if case for the buttons can i add ftp commands there or i need func always?

$scriptname=(is the name of the file i want to send?

$templocation= u mean the server folder i want to copy file?

$dir =file is only one so it will not be needed

is there something more small and simple like connect server copy file and send in the folder u want? because it isnt so easy for me.

$scriptname - is the path and name of a temporary file that is a parameter file for FTP. example: c:\temp\temp.ftp

The above file is an answer file to FTP. it contains the commands for FTP to execute. I can be deleted after the sucessful transfer is complete.

$temploaction - is the c:\temp\ part of $scriptname - in this example

If you don't need $dir then remove the line "FileWrite($ftpfile, "Mkd " & Chr(34) & $dir & Chr(34) & @CRLF)"

mkd means make a directory or folder on the server.

cd means change directory or folder on the server.

lcd means change directory or folder on the local machine.

Sorry I don't know of a simpler way at the moment. Hope this helps.


It is usually easier to make something better, than to invent it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

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.