Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

306
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda