Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

309
Visualizações
How can I send a file's contents as a POST parameter using cURL?

I'm trying to use cURL to POST the contents of a file, as if I'd pasted that contents in to an html textarea. That's to say I don't want to upload the file, I just want a post parameter called foo to be filled with text from a file called bar.txt. bar.txt's contents may include newlines, quotes, and so on.

Is this possible?

Thanks.

Edit: I found out how to do it in the end:

curl --data-urlencode "foo@bar.txt" http://example.com/index.php

This will take the contents of the file bar.txt, url encode it, place the resultant string in a parameter called foo in a POST request of http://example.com/index.php.

I can't speak to whether the solutions others have suggested will work or not, but the one above seems like the best way.

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

You can by doing something like:

$ curl --data "foo:$(cat foo.txt)" http://localhost/yourfile.php

Note that you'll probably want to encode the file, as cacheguard said. To encode it in base64, just modify the previous command like this:

$ curl --data "foo:$(cat foo.txt | base64)" http://localhost/yourfile.php
over 4 years ago · Santiago Trujillo Relatório

0

You should encode/decode the content of your file (for instance by using the base64 command under Linux).

file foo.txt:

8<----------------------------
Hello World
I am a Secure Web Gateway
8<----------------------------
base64 foo.txt | base64 -d
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda