SOLVED - How to create a new folder on server using FTP

Creating desktop or client-server database solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
admin12
Posts: 412
Joined: Wed May 11, 2011 9:47 am

SOLVED - How to create a new folder on server using FTP

Post by admin12 » Wed Jul 27, 2011 7:01 pm

I need to auto-create a file folder on a file server (already set up) based on the user's first and last name.

I have already read through the ftp tutorial and got it working - but I need to create the folder first and then upload files to it.

To add, I have the two fields set up - fldFirstName and fldLastName,

I know that the two together woulkd be:

put the text of field "fldLastName" &space & the text of field "fldFirstName" into FullName

However, how do I now create a FOLDER (the name of which will be FullName) on my file server using ftp?

Mike
Last edited by admin12 on Thu Jul 28, 2011 1:20 pm, edited 1 time in total.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: How to create a new folder on server using FTP

Post by Mark » Thu Jul 28, 2011 1:20 am

Hi Mike,

I don't know which tutorial you are referring to. Does it discuss the libUrlFtpCommand? If not, then please head over to the LiveCode dictionary and read everything about this command.

Usually, you can use the MKD command to create a new directory.

Code: Select all

get libURLftpCommand("MKD dirname",example.net:75,"root",field "password")
You need to change to the directory where you want to create the new directory. You can use the CWD command for this. On most server, you send the following commands to create a directory in your public directory:

CWD public_html
MKD dirname

Always check the value returned by libUrlFtpCommand for errors before continuing with the next command.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

admin12
Posts: 412
Joined: Wed May 11, 2011 9:47 am

Re: How to create a new folder on server using FTP

Post by admin12 » Thu Jul 28, 2011 1:27 am

Mark,

Thanks.

get libURLftpCommand("MKD dirname",example.net:75,"root",field "password")

OK, so if the path is ftp.travelandworkusa.com/public_html/userfiles,"username","password")

That would be

get libURLftpCommand("MKD dirname", ftp.travelandworkusa.com/public_html/userfiles,"username","password")

Now, if I need the dirname to be the user's last and first name, I have already created the following:

put SurName &"_" &FirstName into FullNameTemp

Is that what I put in the dirname? Can I just put the variable FullNameTemp in there, like this:

get libURLftpCommand("MKD " &FullNameTemp, ftp.travelandworkusa.com/public_html/userfiles,"username","password")

Lastly, how do invoke this? Is it automatic (I thought the GET command asks for something and puts it in a variable) or do I need to CALL it somehow?

Seriously, thanks for your help. I am under pressure to get this done.

Mike

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: How to create a new folder on server using FTP

Post by Mark » Thu Jul 28, 2011 1:34 am

Mike,

The syntax

Code: Select all

get libURLftpCommand("MKD " &FullNameTemp, ftp.travelandworkusa.com/public_html/userfiles,"username","password")
seems correct, except that you have no obligatory double quotes around the URL.

Do you realise that put and get are commands just like beep and wait? Just give it a try.

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

admin12
Posts: 412
Joined: Wed May 11, 2011 9:47 am

Re: How to create a new folder on server using FTP

Post by admin12 » Thu Jul 28, 2011 1:43 am

get libURLftpCommand("MKD " &FullNameTemp, "ftp.travelandworkusa.com/public_html/userfiles","username","password")

I also tried the short URL ftp.travelandworkusa.com and then added /public_html/userfiles/ to the FullNameTemp file - did not work either.

Neither created a new directory.

It should have created the following directory:

travelandworkusa.com/public_html/userfiles/Felker_Scotty

Obviously, I changed the username and password to the correct ones and the port will auto default to 21.

I am VERY rusty with my linux commands. I know the mkdir (tried the mkdir command and it did not help at all) command and I thought it was cd.. to go back. However, my brain just cannot seem to handle how to structure this to work.

The files need to go to the following place:

travelandwork.com/public_html/userfiles/NEW DIRECTORY HERE

Now, the database itself is not on this server nor is any websites that will be used, so I am not sure if I even need to back out of the directories.

What am I doing wrong and how can I get it working?

Mike

admin12
Posts: 412
Joined: Wed May 11, 2011 9:47 am

Re: How to create a new folder on server using FTP

Post by admin12 » Thu Jul 28, 2011 3:49 am

This is so frustrating. I am so closed to finished.

Thanks for the help so far and I hope this one gets solved soon.

Mike

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: How to create a new folder on server using FTP

Post by Mark » Thu Jul 28, 2011 10:26 am

Mike,

As I already wrote, libURLftpCommand returns a value. If you post executation errors and values returned by functions and commands right-away, then we can help you more quickly.

I'm also thinking you might try to simply upload a file. If you specify a complete path, the server might create the non-existent folder. This isn't a solution if you want to be able to create empty directories.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

admin12
Posts: 412
Joined: Wed May 11, 2011 9:47 am

Re: How to create a new folder on server using FTP

Post by admin12 » Thu Jul 28, 2011 1:11 pm

Mark,

I thought about that - I created an empty text file and was thinking about uploading it. Hmmmm.

How do I get the returning value? Using the put? How? I'll try it now.

Here is what I wrote:

put libURLftpCommand("MKDIR " &FullNameTemp, "ftp.travelandworkusa.com","username","password") into FTPme
answer FTPme

I tried it - I get the following error: 500 unknown command

Mike

admin12
Posts: 412
Joined: Wed May 11, 2011 9:47 am

Re: How to create a new folder on server using FTP

Post by admin12 » Thu Jul 28, 2011 1:19 pm

SOB.

I changed the MKDIR to MKD like you suggested and it worked.

Hot damn!!!!!!!!

Thank you. This was the MOST annoying hurdle thus far.

Thank you thank you thank you.

Mike

Post Reply