Re: How to encode names for FTP ?
Date: Tue, 4 Apr 2006 16:26:40 +0200
ok so if I understood correctly, if I have a string like :
I must curl_escape :
Did I get it right ? I'm somehow still unsure that I must encode things like
www.server.com because of the dots in it...
Thank you in advance
On 4/3/06, Daniel Stenberg <daniel_at_haxx.se> wrote:
> On Fri, 31 Mar 2006, Silex wrote:
> > Basically, I'm uploading a file and its name may contains spaces or
> > characters like %.
> Then upload to a URL and encode the URL properly - URL encoded is usually
> > As far as I understood, whenever I set CURLOPT_URL, I must replace the %
> > contained in it with %25, is that right ?
> Yes, all reservered characters must be replaced with %HH where HH is the
> hexadecimal representation.
> > I must not try to add quotes or whatever if there's a space in the file
> > name, and I must only treat the % char.
> A space is %20 in a URL.
> > It seems that I should *not* use curl_escape for that because otherwise
> > things like / etc get encoded as well.
> When you create a URL you need to escape each individual part of the URL
> then append them all and create the URL with the proper "part" separators.
> Like for directory names you need to escape the names but then join them
> a slash separating them.
> > Now, after uploading the file, I use a curl_slist along with
> > CURLOPT_POSTQUOTE to do a chmod on the file. Here too, should I replace
> > % the same way for the filename ?
> No. The *QUOTE options are plain strings you send to the FTP server
> and untouch by libcurl. You need to send those strings to the server in a
> format that the server expects and wants them to be. That is actually a
> less defined area. RFC959 is not at all very clear on how to encode
> characters. At least I didn't find it the last time I checked.
> Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Received on 2006-04-04