Sorry if this is not the right place to post this but i really need help

I'm trying to upload a file to a remote server by using vbscript

below is a code :

    Dim fso, f, myFile
    Set fso = CreateObject("Scripting.FileSystemObject")
    myFile =$URL
    Set f = fso.GetFile (myFile)
    Dim sql ,nRows,NN,i,sql2,numCur
    $Status =""
    NN=$URL
    $FileCopy( NN ,$GetAppPath() & "Web\Media\", 1000 )

the problem is with this code i can copy the file only in the same PC but it didn't work when i try with different machin i mean from client to server

any help any comment appreciated.
Thanks

Recommended Answers

All 4 Replies

Hard to give a definite answer without a few specifics. I don't see how you are doinig the file copy. You declare a FileSystemObject but you don't use the CopyFile method of that object. I don't know the values of $URL or the destination path. As far as I know, $FileCopy and $GetAppPath are not part of vbScript. What access rights do you have on the remote server? Is the server on the same LAN?

You use fso.GetFile and return a file object in f but you don't use f for anything.

Hi, Reverend Jim

I'm developing the application using Indusoft studio

The $FileCopy and $GetAppPath are the built in function of Indusoft Studio
where
$FileCopy : Copies the file(s) configured in the strSourceFile parameter to the path/file configured in the strTargetFile parameter.

and

$GetAppPath : Returns the file path of the project folder.

and yes the server is on the same LAN.

and yes i do use f in another part of the code here is what i have done

                        Dim fso, f, myFile 
                        Set fso = CreateObject("Scripting.FileSystemObject") 
                        myFile =$URL 
                        Set f = fso.GetFile (myFile)

                        Dim sql ,nRows,NN,i,sql2,numCur
                        $Status ="" 
                        NN=$URL
                        $FileCopy( NN ,$GetAppPath() & "Web\media\", 1000 )
                        '' where (NN = Source file,$GetAppPath() & "Web\media\ = the destination file that i want to past the file,1000 = time out,optional)


                        '' belowis where i use f

                        $URL=$GetAppPath() & "Web\Media\" &f.name
                        sql="INSERT INTO andonsystem.file_video(File_Name,Description) VALUES ('"& f.Name &"','"&$URL&"')"
                        $DBExecute ("AndonSystemDatabase",sql,"",1000000000,"Status")

So please let me explain you in specific so you can help me :)

what i'm trying to do is copy a file from client to server

the actual file must be copy and past in the web\media folder of the server machine and the name of that file will be saved in the database that is MySql
But what happened is the actual file did not copy and past to the server. the code is only works in the same PC it doesn't work with server and client manner
i did google and found some answer: They said to specify the IP address of the server so i tried instead of

$FileCopy( NN ,$GetAppPath() & "Web\media\", 1000 )

change to
$FileCopy( NN ,$GetComputerIP() & "Web\media\", 1000 )

but still doesn't work

Thanks.

I suggest you just use the CopyFile method of the Scripting.FileSystemObject. It has two forms

fso.CopyFile srcefile,destfile
fso.CopyFile srcefile,destpath

If the second parameter ends in "\" then it assumes form 2 and copies the file to the given folder otherwise it copies the file to the given destination file. Eighty percent or so of the scripts I wrote between 1998 and 2008 did some sort of file copy as part of the processing and except for the very few that used FTP, I always used the builtin file copy methods. Almost all of the code I wrote in that period was vbScript.

Thanks Reverend Jim , I will try and let you know.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.