diff options
author | Daniel Stenberg <daniel@haxx.se> | 2001-12-11 00:48:55 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2001-12-11 00:48:55 +0000 |
commit | c63ca99c1c99cff46b1184356d2639dddf3551c6 (patch) | |
tree | aec8264a196cb5b8ddc7ee0ea600002621f1f80a /src | |
parent | 1c99c4ad11e7f5cef70302ff8f641bb7c68ac1a6 (diff) | |
download | curl-c63ca99c1c99cff46b1184356d2639dddf3551c6.tar.gz |
when the file name given to -T is used to build an upload path, the local
directory part is now stripped off and only the actual file name part will be
used
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/main.c b/src/main.c index 589892b34..e4bd9efa0 100644 --- a/src/main.c +++ b/src/main.c @@ -2091,17 +2091,29 @@ operate(struct Configurable *config, int argc, char *argv[]) to be able to do so, we have to create a new URL in another buffer.*/ - urlbuffer=(char *)malloc(strlen(url) + strlen(config->infile) + 3); + /* We only want the part of the local path that is on the right + side of the rightmost slash and backslash. */ + char *filep = strrchr(config->infile, '/'); + char *file2 = strrchr(filep?filep:config->infile, '\\'); + + if(file2) + filep = file2+1; + else if(filep) + filep++; + else + filep = config->infile; + + urlbuffer=(char *)malloc(strlen(url) + strlen(filep) + 3); if(!urlbuffer) { helpf("out of memory\n"); return CURLE_OUT_OF_MEMORY; } if(ptr) /* there is a trailing slash on the URL */ - sprintf(urlbuffer, "%s%s", url, config->infile); + sprintf(urlbuffer, "%s%s", url, filep); else /* thers is no trailing slash on the URL */ - sprintf(urlbuffer, "%s/%s", url, config->infile); + sprintf(urlbuffer, "%s/%s", url, filep); url = urlbuffer; /* use our new URL instead! */ } |