加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – 使用libcurl上传带有特殊字符的文件名

发布时间:2020-12-16 06:53:09 所属栏目:百科 来源:网络整理
导读:尝试使用curl FTP将文件HU98373 TRRepr#o4_201702061135_34从本地系统复制到远程目标. 在远程系统中,它使用HU98373 TRRepr而不是HU98373 TRRepr#o4_201702061135_34创建了文件.我不知道为什么不考虑’#’字符 请检查以下代码. remoteFileUrl = ftp://IPADRES
尝试使用curl FTP将文件HU98373 TRRepr#o4_201702061135_34从本地系统复制到远程目标.

在远程系统中,它使用HU98373 TRRepr而不是HU98373 TRRepr#o4_201702061135_34创建了文件.我不知道为什么不考虑’#’字符

请检查以下代码.

remoteFileUrl = ftp://IPADRESS/HOME/HU98373+TRRepr#o4_201702061135_34.tmp/C20170206.1135-20170206.1140

curl_easy_setopt(m_CurlSessionHandle,CURLOPT_URL,remoteFileUrl);
                        curl_easy_setopt(m_CurlSessionHandle,CURLOPT_UPLOAD,ON);

                        // Set the input local file handle
                        curl_easy_setopt(m_CurlSessionHandle,CURLOPT_READDATA,localFileHandle);

                        // Set on/off all wanted options
                        // Enable ftp data connection
                        curl_easy_setopt(m_CurlSessionHandle,CURLOPT_NOBODY,OFF);

                        // Create missing directory into FTP path
                        curl_easy_setopt(m_CurlSessionHandle,CURLOPT_FTP_CREATE_MISSING_DIRS,ON) ;

                        // Set the progress function,in oder to check the stop transfer request
                        curl_easy_setopt(m_CurlSessionHandle,CURLOPT_NOPROGRESS,OFF);
                        curl_easy_setopt(m_CurlSessionHandle,CURLOPT_PROGRESSFUNCTION,progressCb);
                        curl_easy_setopt(m_CurlSessionHandle,CURLOPT_PROGRESSDATA,this);

                        CURLcode curlOperationResult = curl_easy_perform(m_CurlSessionHandle);

谁可以帮我这个事

解决方法

URL由以下部分组成:

scheme:[//[user:password@]host[:port]][/]path[?query][#fragment]

characeter#表示URL片段.您必须对#字符进行URL编码,以使其不被解释为片段分隔符.

编码后,服务器将按预期解析URL,并生成正确的文件名.

以下问题显示了如何在C中执行此操作:

Encode/Decode URLs in C++

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读