简体   繁体   中英

Linux CURL how to POST file and data url encoded same time?

I have a problem to send a POST request with a text file and some key=value (value contains special characters and it needs to be encoded, eg: query=select c + a % b).

I've tried like this and it returns error Warning: You can only select one HTTP request!

curl -F "file=@path_to_text_file" 
--data-urlencode "query=select c + a % b" "http://localhost:8082/app"

remove --data-urlencode then it can run but the value of query is not encoded.

I prefer to not need to encode query manually.

这将进行上传,然后发送发布请求

curl -F "file=@path_to_text_file" "http://localhost:8082/app" --next --data-urlencode "query=select c + a % b" "http://localhost:8082/app"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM