May-25-2019, 02:15 AM
(This post was last modified: May-25-2019, 02:15 AM by Pedroski55.)
I have a godaddy webpage. I don't use it much. Mainly just for trying things out.
I have managed enough PHP to get files uploaded to my webhost from a webpage. The user just clicks a button to select a file, then clicks the upload button
The PHP to validate the files, pack them in an email and send them seems quite complex. Too much for me! I need to install PHPMailer or Pear on the server and do all kinds of complicated stuff it seems. Python to the rescue!
I found I can get a file simply like this:
I want to
1. download all files in the path,
2. save them under whatever name they already have,
3. then delete them on the web server.
On my laptop, when I want to do something with all files in a directory, I use:
and then:
I have managed enough PHP to get files uploaded to my webhost from a webpage. The user just clicks a button to select a file, then clicks the upload button
The PHP to validate the files, pack them in an email and send them seems quite complex. Too much for me! I need to install PHPMailer or Pear on the server and do all kinds of complicated stuff it seems. Python to the rescue!
I found I can get a file simply like this:
import requests file_url = "http://www.mywebpage.com/php/uploads/chineseYearAnimals.txt" # URL of the files to be downloaded is defined as file_url r = requests.get(file_url) # create HTTP response object # send a HTTP request to the server and save # the HTTP response in a response object called r with open("/home/pedro/Downloads/download1.txt",'wb') as f: # Saving received content as a file in # binary format # write the contents of the response (r.content) # to a new file in binary mode. f.write(r.content) f.close()Could you please help me modify this?
I want to
1. download all files in the path,
2. save them under whatever name they already have,
3. then delete them on the web server.
On my laptop, when I want to do something with all files in a directory, I use:
Quote:files = os.listdir(path)
and then:
Quote:for file in files:I need the web version of that.
do tricky stuff