file upload to server
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 101
- Joined: Wed Dec 22, 2010 8:17 pm
file upload to server
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
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
Re: file upload to server
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
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 503 times
-
- Posts: 101
- Joined: Wed Dec 22, 2010 8:17 pm
Re: file upload to server
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?
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?
Re: file upload to server
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
should be
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
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
(otherwise, the word "gRepertoireImage" whould be added to the name of the uploaded file)put the last item of tFileForUpload into tFileName
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
-
- Posts: 101
- Joined: Wed Dec 22, 2010 8:17 pm
Re: file upload to server
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
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
Re: file upload to server
You should not give up !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
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.
Re: file upload to server
maybe try the simpler "put" form instead of liburlftpupload (for testing porpouse):
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
Code: Select all
put "this is a test" into theText
put theText into url "ftp://Login:PW@ValidURL/test.txt"
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
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
-
- Posts: 101
- Joined: Wed Dec 22, 2010 8:17 pm
Re: file upload to server
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
Thanks again
Steve
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
Thanks again
Steve
Re: file upload to server
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
xTalk coding since 1990
Developer of lcResTool and lcMover and other developer tools
https://charlesbuchwald.com
-
- VIP Livecode Opensource Backer
- Posts: 9960
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: file upload to server
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
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: file upload to server
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
xTalk coding since 1990
Developer of lcResTool and lcMover and other developer tools
https://charlesbuchwald.com