ftp a file from a form

I am building a sample application that would normally run over an intranet in an internet environment, so the normal file system commands I would use are not available.

I need to be able to ftp a file to a server which is an sql server rather than the web server that is hosting the page.

I want the user to be able to use a form to browse to a file (that bit I can do!) and then on submit the file should be FTP'd to the server.  I have: the server IP, the directory structure I want to FTP to, the user name and the password.

Is there a simple script (I'm not a techie) that I can use to do the FTP?

The application is SQL/ASP based.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I don't know what do you mean by ftp to file server.

Basically SQL server is not a FTP server.

To upload a file to database

You need to have multipart html form, asp page and database table with blob column to hlod your file in database

Ryan ChongCommented:
what browser is you refer to?

Actually you can do it in IE, without any programming needed, just try typing the FTP address on a IE browser address bar, and it will prompt you for the username and password.

After logged in, you can just do a "Copy and Paste" just the same you did on your Windows folder.

If you want an Interface, i suggest you download a FTP client from some popular softwares download sites instead. No worth to research and develop a FTP component here.

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

bigoldbirdAuthor Commented:

Thank you for your comments.  I know that an SQL server is not an FTP server but in this instance I need to get a file from a client computer onto the SQL server so that I can run an BULK INSERT procedure.

I can't use ASPupload (well I don't think so) because the SQL server is not the IIS server where the loading page will be hosted.

Well, you're going to need to create //& install an application on the SQL server.. that allows you to transmit files to it.. Such as an FTP server.

Just basically an application that creates a Server Socket, and allows transmission of a file.

Note, I can't see how you can transfer a file using just HTML -- I'm pretty sure it can't be done.. you'll need to use a CGI language most likely for the transmission. (e.g. PHP, JSP, ASP, ..).

bigoldbirdAuthor Commented:
I did ask this question on the ASP pages but didn't get an answer at all.

I have FTP working to the server but I wanted a solution that would only involve the usering in putting the file without being able to browse or download files from the server.  Not for particularly security reasons, just to limit the risk of error and to make it as simple as possible for the user.

Okay, well, I personally don't do ASP (I avoid all Microsoft languages (bar C#/VC++) ;-)).

However, I can give you the code to upload a file in PHP or JSP ... if either, choose one, and I'll direct you on how to use it, and post the necessary code.

You could upload the file to the IIS server and then move it via a batch file over the network to the SQL server.  Refer to http://www.experts-exchange.com/Programming/Q_20975928.html#10983398 for the command line in your batch file using xcopy.

Your ASP will look like this:

strFilePath = "<Drive>:\<Directory>\<file>.bat"
Set objWshShell = server.CreateObject("WScript.Shell")
rtn = objWshShell.Run(strFilePath, 1, True)
Set objWshShell = Nothing

This is untested, so it may require some tweaks.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bigoldbirdAuthor Commented:
Thank you both :-)  I actually did it with a simple ftp script in the end which is fairly similar to ERNesbitts solution.  I split the points because you have both been great.

Again, thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.