Skip to main content
Fix typos
Source Link
coffee-grinder
  • 27.7k
  • 19
  • 59
  • 82

a fiewA few points :

  • make sure to submit your request to the corectcorrect url ( the form 'action' )
  • use the data parameter to submit other form fields ( 'dir', 'submit' )
  • include the name of the file in files ( this is optional )

code :

import requests

url = 'http://example.com' + '/upload.php'
data = {'dir':'/uploads/', 'submit':'Submit'}
files = {'file':('1.jpg', open('1.jpg', 'rb'))}
r = requests.post(url, data=data, files=files)

print(r.content)

a fiew points :

  • make sure to submit your request to the corect url ( the form 'action' )
  • use the data parameter to submit other form fields ( 'dir', 'submit' )
  • include the name of the file in files ( this is optional )

code :

import requests

url = 'http://example.com' + '/upload.php'
data = {'dir':'/uploads/', 'submit':'Submit'}
files = {'file':('1.jpg', open('1.jpg', 'rb'))}
r = requests.post(url, data=data, files=files)

print(r.content)

A few points :

  • make sure to submit your request to the correct url ( the form 'action' )
  • use the data parameter to submit other form fields ( 'dir', 'submit' )
  • include the name of the file in files ( this is optional )

code :

import requests

url = 'http://example.com' + '/upload.php'
data = {'dir':'/uploads/', 'submit':'Submit'}
files = {'file':('1.jpg', open('1.jpg', 'rb'))}
r = requests.post(url, data=data, files=files)

print(r.content)
added 37 characters in body
Source Link
t.m.adam
  • 15.4k
  • 3
  • 34
  • 54

Aa fiew points :

  • post the filemake sure to 'upload.php'submit your request to the corect url ( htmlthe form 'action' )
  • include the name ofuse the file in filesdata parameter to submit other form fields ( this is optional'dir', 'submit' )
  • include all the post dataname of the file in datafiles ( 'dir', 'submit'this is optional )

code :

import requests

url = 'http://example.com' + '/upload.php'
data = {'dir':'/uploads/', 'submit':'Submit'}
files = {'file':('1.jpg', open('1.jpg', 'rb'))}
data = {'dir':'/uploads/', 'submit':'Submit'}
r = requests.post(url, files=filesdata=data, data=datafiles=files)

print(r.content)

A fiew points :

  • post the file to 'upload.php' ( html form 'action' )
  • include the name of the file in files ( this is optional )
  • include all the post data in data ( 'dir', 'submit' )

code :

import requests

url = 'http://example.com' + '/upload.php'
files = {'file':('1.jpg', open('1.jpg', 'rb'))}
data = {'dir':'/uploads/', 'submit':'Submit'}
r = requests.post(url, files=files, data=data)

print(r.content)

a fiew points :

  • make sure to submit your request to the corect url ( the form 'action' )
  • use the data parameter to submit other form fields ( 'dir', 'submit' )
  • include the name of the file in files ( this is optional )

code :

import requests

url = 'http://example.com' + '/upload.php'
data = {'dir':'/uploads/', 'submit':'Submit'}
files = {'file':('1.jpg', open('1.jpg', 'rb'))}
r = requests.post(url, data=data, files=files)

print(r.content)
deleted 5 characters in body
Source Link
t.m.adam
  • 15.4k
  • 3
  • 34
  • 54

A fiew suggestionspoints :

  • post the file to 'upload.php' ( thehtml form 'action' )
  • include the name of the file in files ( '1.jpg'this is optional )
  • include all the post data in data ( 'dir', 'submit' )

code :

import requests

url = 'http://example.com' + '/upload.php'
files = {'file':('1.jpg', open('1.jpg', 'rb'))}
data = {'dir':'/uploads/', 'submit':'Submit'}
r = requests.post(url, files=files, data=data)

print(r.content)

A fiew suggestions :

  • post the file to 'upload.php' ( the form 'action' )
  • include the name of the file in files ( '1.jpg' )
  • include all the post data in data ( 'dir', 'submit' )

code :

import requests

url = 'http://example.com' + '/upload.php'
files = {'file':('1.jpg', open('1.jpg', 'rb'))}
data = {'dir':'/uploads/', 'submit':'Submit'}
r = requests.post(url, files=files, data=data)

print(r.content)

A fiew points :

  • post the file to 'upload.php' ( html form 'action' )
  • include the name of the file in files ( this is optional )
  • include all the post data in data ( 'dir', 'submit' )

code :

import requests

url = 'http://example.com' + '/upload.php'
files = {'file':('1.jpg', open('1.jpg', 'rb'))}
data = {'dir':'/uploads/', 'submit':'Submit'}
r = requests.post(url, files=files, data=data)

print(r.content)
added 4 characters in body
Source Link
t.m.adam
  • 15.4k
  • 3
  • 34
  • 54
Loading
Source Link
t.m.adam
  • 15.4k
  • 3
  • 34
  • 54
Loading