file upload to server

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Steve Denney
Posts: 101
Joined: Wed Dec 22, 2010 8:17 pm

file upload to server

Post by Steve Denney » Wed Nov 09, 2011 1:59 am

Hi, I've got a livecode product utility. It handles ordering and updating the database etc.

I need users to be able to upload image files to an online store (i.e. when updating or adding products).

They need to do this from within the poduct utility.

I'm happy to use either 1. libURLftpUploadFile or 2. posting to php to do this.

Any solution will be much appreciated,

Steve

Here's what I've tried so far; I can't get either method to work.

First 1...

I've tried using :

put "C:/test_file.txt" into tFileForUpload
put "ftp://userName:password@theDomainName/w ... t_file.txt" into tDestination
libURLftpUploadFile tFileForUpload, tDestination

I've also tried http: in place of ftp:

Neither worked. Nothing appears to happen.

Then 2.

I've already used posting to php to update the online mysql database and that works just fine, but the submit button on an html page for an upload is a little different...

<form action="upload_file.php" method="post" enctype="multipart/form-data"> apparently creates a $_FILES array

whereas the usual post <form action="welcome.php" method="post"> simply populates a $_POST array

And (of course) livecode has to replace the submit button's action.

Once again any solution would be great, thanks

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: file upload to server

Post by bangkok » Wed Nov 09, 2011 6:50 am

Hello,

Here is a stack you can work with.

Be sure to put your own ftp server address, login and password (at the top of stack's script).

This stack allows you to :
-select a file
-upload the file
-it shows a progress bar and handle errors
Attachments
FTP_UPLOAD.zip
(1.67 KiB) Downloaded 478 times

Steve Denney
Posts: 101
Joined: Wed Dec 22, 2010 8:17 pm

Re: file upload to server

Post by Steve Denney » Wed Nov 09, 2011 7:25 am

Hi Bangkok, thanks, I did simplify my efforts a little though, I already got hold of a (very) similar stack called Download_Upload.rev (which I didn't mention firstly to keep things simple and 2ndly 'cause I couldn't find where I got it from to to properly credit the creator).

Anyway, using either of these uploaders I get the stack's custom error message if I use the stack code as written, but the message comes whatever password, details etc I put in.

If I alter the script to http (which apparently helped someone in an earlier post) I get no error message, but no success message either.

I've tried all sorts of variations too, my login details work with dreamweaver but when used in the "ftp://userName:password@theDomainName/w ... t_file.txt" format they fail or with 'http:' they do nothing at all.

Any ideas?

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: file upload to server

Post by bangkok » Wed Nov 09, 2011 9:17 am

I can assure you : it works.

From 2 different machines, I can upload successfully files to my ftp server. I just did it.

I made one mistake though :

the line

Code: Select all

put gRepertoireImage&the last item of tFileForUpload into tFileName
should be
put the last item of tFileForUpload into tFileName
(otherwise, the word "gRepertoireImage" whould be added to the name of the uploaded file)

So to summarize, I see only 3 solutions :

-you have a network/internet connection issue (firewall ?)

-you made a mistake with your login and/or password.

-you have an issue with the rights of your login and the directory of the ftp server

Steve Denney
Posts: 101
Joined: Wed Dec 22, 2010 8:17 pm

Re: file upload to server

Post by Steve Denney » Thu Nov 10, 2011 1:11 am

What you say makes sense, yet, I've shut down the firewall, confirmed login details and rang my service provider who told me ftp should work fine.

I've now tried all 3 of livecode's upload commands. The put command is the only one that yields useful result information. It's telling me: error 530 Login incorrect
BUT if I type the ftp URL syntax into my browser address bar:
ftp://login:password@domain_name/www/htdocs/ (minus the upload file name test.jpg) I get straight in (as logged in).

I've tried replacing the domain name with the ip address (in case it wasn't being resolved),
and creating a template file on the server, in case file creation somehow wasn't working.

No joy, and I've spent almost 2 days on this.

And the sad truth is I don't even really need it to work on our server (although it would save me work) I really need it to work on future client's websites (thought fills me with horror).

I'm going to start another thread, and beg for a php post solution. However if anyone comes up with a lc ftp solution it'd be great.
Thanks
Steve

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: file upload to server

Post by bangkok » Thu Nov 10, 2011 8:40 am

Steve Denney wrote: I'm going to start another thread, and beg for a php post solution. However if anyone comes up with a lc ftp solution it'd be great.
Thanks
You should not give up !

Some other thoughts :

-I've you tried actually to copy a file to your ftp server, using the login and password and a regular FTP client (like Filezilla) ?
it would be good to try it, just to be sure that rights are okay.
My point : maybe rights are not okay, you can just connect, read the directory content, but not write into it.

-use a "way around" : try the LiveCode stack with another FTP server, and see what's going on. That would help to see that everything is fine and working as it should be.

-have you tried the stack with another PC ?

It has to work. It would be really annoying to use a php script. Your clients deserve the right to use an app that is able to connect to ftp server. :)

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1236
Joined: Sat Apr 08, 2006 1:10 pm
Location: Zurich
Contact:

Re: file upload to server

Post by BvG » Thu Nov 10, 2011 12:36 pm

maybe try the simpler "put" form instead of liburlftpupload (for testing porpouse):

Code: Select all

put "this is a test" into theText
put theText into url "ftp://Login:PW@ValidURL/test.txt"
Note: if your password or login contains chars that are not allowed in urls, you need to urlencode them before using them in ftp commands from LC (see the urlEncode() function in the dictionary). For example:

normal:
Login: björnke
password: 12@e*dd[4#

urlencoded:
Login: bj%9Arnke
PW: 12%40e*dd%5B4%23
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

Steve Denney
Posts: 101
Joined: Wed Dec 22, 2010 8:17 pm

Re: file upload to server

Post by Steve Denney » Thu Nov 10, 2011 8:39 pm

Urlencode...
That's it BvG. I can't thank you enough, it's such a weight off my shoulders, really is.
And thanks Bangkok for sticking with this. As you can probably guess I've been losing trust in runrev over the last year or so--bad experiences with both the web and server platforms.
So! My faith in livecode (and causality ) is somewhat restored :D
Thanks again
Steve

Peregrine
Posts: 53
Joined: Sun Jan 10, 2010 10:33 pm
Location: Always changing!
Contact:

Re: file upload to server

Post by Peregrine » Wed Jun 18, 2014 12:15 am

Hey, thanks, bangkok. I was having some of my own issues with libURLftpUploadFile, and your example stack was just what I needed to see it work.
Charles Buchwald
xTalk coding since 1990
Developer of lcResTool and lcMover and other developer tools
https://charlesbuchwald.com

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9847
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: file upload to server

Post by FourthWorld » Wed Jun 18, 2014 1:46 am

Unless this is for your own personal use you may want to replace the FTP call with a call to a CGI that handles file uploads. FTP sends login credentials in plain text, so anyone using the app (or any interloper) could see the network stream and get control over that account on your server.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Peregrine
Posts: 53
Joined: Sun Jan 10, 2010 10:33 pm
Location: Always changing!
Contact:

Re: file upload to server

Post by Peregrine » Wed Jun 18, 2014 4:23 am

Thanks, Richard. I'm aware of the vulnerability, and it should be OK for this little project. Really looking forward to having SFTP in LC, though.
Charles Buchwald
xTalk coding since 1990
Developer of lcResTool and lcMover and other developer tools
https://charlesbuchwald.com

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”