3

I'm going to start of by noting that I have next to no python experience.

alt text http://www.aquate.us/u/9986423875612301299.jpg

As you may know, by simply dropping a shortcut in the Send To folder on your Windows PC, you can allow a program to take a file as an argument.

How would I write a python program that takes this file as an argument?

And, as a bonus if anyone gets a chance -- How would I integrate that with a urllib2 to POST the file to a PHP script on my server?

Thanks in advance.

Edit-- also, how do I make something show up in the Sendto menu? I was under the impression that you just drop a shortcut into the SendTo folder and it automatically adds an option in the menu... Never mind. I figured out what I was doing wrong :)

1
  • If you figured something out then you should add that solution as a edit below your question so that it will help others who stumble on your question as well. Commented Jul 24, 2018 at 6:20

2 Answers 2

7
  1. Find out what the dragged file was: http://docs.python.org/library/sys.html#sys.argv
  2. Open it: http://docs.python.org/library/functions.html#open
  3. Read it in: http://docs.python.org/library/stdtypes.html#file.read
  4. Post it: http://docs.python.org/library/urllib2.html#urllib2.urlopen
Sign up to request clarification or add additional context in comments.

1 Comment

Perfect. Thanks so much for the links. This'll be a breeze now :)
2
import sys

for arg in sys.argv:
  print arg

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.