The Inferno

It is a fallacy to state that something exists just because it can't be proven that it doesn't

  • Home

20

Feb

Direct Upload to FTP

Posted by Viren  Published in Programming, UploadToFTP

Many’s the time I’ve surfed the vast wonders of the cybernetic ocean and wondered, “Wouldn’t it be nice to have this bit of coral back home, resting peacefully on the mantelpiece?”. Well, perendinate no longer! I present to you my first Firefox add-on, an add-on that lets you upload images you see on webpages directly to your website. Let me explain. If I see an image I like or wish to re-post on my blog, I have to do the following:

  1. Right click on image
  2. Save to hard drive
  3. Fire up an FTP client, Filezilla in this case
  4. Connect to my FTP server
  5. Load the directory with the downloaded image in the left pane, and the appropriate FTP directory in the right pane
  6. Upload the file

My add-on automates these steps. Since I don’t know how to use Javascript to upload a file to an FTP server, the script calls a PHP script which does the heavy lifting. I repeat that again: you must have a PHP-enabled webserver to run this add-on successfully. It doesn’t need to be a hosted one, I just run apache on my box and point the javascript to localhost. More detailed instructions are at the bottom. First, we look at how it works.

If you’re on some random site and think you want an image for your personal post or to share with others without being a leech on the original host, you right click on an image to see the context menu augmented by the “Upload To FTP” sub-menu.

Select the first option, “Images”. The second menu, “Fav 2″ can be customized to whatever you want, if you’re so inclined, but it’s mostly there to show that other options can be added. If you right-click on a non-text element the context menu is still augmented. I followed the Mozilla instructions but wasn’t able to get the sub-menu to not show up on non-image environments. If anyone figures it out after looking at my code, please drop me a line.

If you try to upload the non-image element, you get an error message stating that non-images cannot be uploaded at this time.

Finally, we check the folder on my website where the images were sent to. If you try to add a file with the same name more than once, it increments the file name by the next digit. I don’t know if this will be useful, but I have often come across several image files with the same name and different content (think Google image search for: Canada) and I’d hate to see them overwritten and end up being the same file. We see:

Here is the zip file containing both the XPI installer for the Firefox add-on, and the imgupload.php file. You can install the add-on by opening it with Firefox (File -> Open File). I’ll submit it to the Firefox add-on repository soon.

UploadToFTP zip file.

As for the PHP file, note that it does no error-checking whatsoever. Use it at your own risk. You’ll need to fill in parameters such as the FTP server name, login, password and upload folder. Once that’s done, host it in the root of your webserver’s public HTML directory and you’re done. If you host it in any other location, such as a subfolder or whatnot, then you need to update the “overlay.js” file in your Firefox profile’s extensions/uploadtoftp@viren.kumar/content folder.

Enjoy, and let me know if this is useful for you or if you’d like to see any upgrades or features.

Tags: direct image upload to FTP, firefox add on, mozilla firefox extension, Programming, uploadToFTP mozilla firefox extension

1 comment

Tags

american politics american right-wing anger beijing book Brutal Death Metal bullshit burnaby cartoon china christmas craigslist crossword death metal demotivational poster elections Funny Gentoo geopolitics graphic novel iran linguistics linux live music metal moustache music One-Armed Bandits pix pseudoscience quotes RCMP religion Republican revolution SATA satire Septoplasty setlist sfu short story skeptic software vancouver webcomic

Categories

  • Adam Rifkin
  • Alan Moore
  • Amitav Ghosh
  • Andrea Levy
  • Andy Kessler
  • Angie Abdou
  • Annabel Lyon
  • Anosh Irani
  • Apuleius
  • Aravind Adiga
  • Arnaldur Indridason
  • Audrey Niefenegger
  • Barry Moser
  • Bernhard Schlink
  • Bill Crider
  • Bill Pronzini
  • Book Excerpts
  • Book Reviews
  • Boris Akunin
  • Brett Weldele
  • Brutal Death Metal
  • Bryce Courtenay
  • C J Cherryh
  • Cathy Malkasian
  • Cervantes
  • Charles Burns
  • Christopher Hitchens
  • Classical
  • Clive Cussler
  • Computer Woes
  • Cormac McCarthy
  • Craigslist
  • D. H. Lawrence
  • Daily Dancer
  • Daniel Clowes
  • Daphne du Maurier
  • Dave Eggers
  • Dave Stewart
  • Diana L Paxson
  • Dominique Lapierre
  • Doris Lessing
  • E. M. Forster
  • Elias Khoury
  • Ellen Datlow
  • Erasmus
  • Ernest Hemingway
  • Frederick Forsyth
  • Funny
  • Gabriel Garcia Marquez
  • Garth Ennis
  • Gavin J. Grant
  • Gentoo
  • Geopolitics
  • George MacDonald Fraser
  • George Orwell
  • Gerald Green
  • Glen David Gold
  • Graham Greene
  • Graphic Novel
  • Gustave Flaubert
  • H H Munro
  • H M Naqvi
  • H. F. Saint
  • Harlan Ellison
  • Harry Harrison
  • Henning Mankell
  • Henry David Thoreau
  • Herbert Wise
  • Hermann Hesse
  • Herodotus
  • Honoré de Balzac
  • Ian Rankin
  • Inebriated
  • Irving Stone
  • Isaac Asimov
  • Jack London
  • James E Parker Jr.
  • James Joyce
  • Jean-Benoit Nadeau
  • Jeffery Deaver
  • Jerome K Jerome
  • Jim Butcher
  • Jim Lacey
  • Jim Mortimore
  • Jimmy McGovern
  • Jo Nesbo
  • Joe R Lansdale
  • John Buchan
  • John Bunyan
  • John Kerschbaum
  • Julie Barlow
  • Karin Fossum
  • Kazuo Ishiguro
  • Kelly Link
  • Ken Follett
  • Larry Collins
  • Lawrence Block
  • Leilah Nadir
  • Les Toil
  • Linda Landrigan
  • Linda Medley
  • Linguistics
  • Linux
  • M G Vassanji
  • Maha Gargash
  • Margaret Atwood
  • Margaret George
  • Marion Zimmer Bradley
  • Martin Cruz Smith
  • Martin Myers
  • Milton
  • Music
  • My Software
  • Nathan Fox
  • Neil Gaiman
  • New York Times Crossword
  • Noam Chomsky
  • One-Armed Bandits
  • P F Kluge
  • Pascal Mercier
  • Pauline Gedge
  • Peter Carey
  • Peter Lovesey
  • Philip Roth
  • Phyllis Cerf Wagner
  • Programming
  • Pseudoscience
  • Ray Bradbury
  • Ray Wiss
  • Religion
  • Republican
  • Rhea Tregebov
  • Richard Tomlinson
  • Rick Geary
  • Robert Bloch
  • Robert Grudin
  • Robert Heinlein
  • Robert Sawyer
  • Robert Venditti
  • Robert Weaver
  • Robertson Davies
  • Rosemary Herbert
  • Ruth L. Ozeki
  • Saki
  • Salman Rushdie
  • Saros Cowasjee
  • Septoplasty
  • Sherman Alexie
  • Short Story
  • Stephen Clarke
  • Stephen Fry
  • Steven Pinker
  • Susan Kandel
  • Susan Wittig Albert
  • Television
  • Terry Pratchett
  • Text Processing
  • The usual
  • Thomas King
  • Tim Parks
  • Tom Robbins
  • Tony Hillerman
  • Travel
  • Umberto Eco
  • UploadToFTP
  • Ursula Hegi
  • Vancouver
  • Vancouver 2010 Winter Olympics
  • Victor Hugo
  • Vikram Chandra
  • Virgil
  • Virginia Woolf
  • William Deverell
  • William S. Burroughs
  • Zdzisław Beksiński

Blogroll

  • Bart’s Blog
  • Berlin Photo Blog
  • Celtic Frost
  • Dev Environment
  • Geoff's Mobile Video Blog
  • Get Juand
  • It’s Curtis for you
  • Nance in France
  • New York Times Crossword Blog
  • Phil's Blog
  • That's Some Catch
  • The Zengerarium

Books

  • Arthur C. Clarke
  • Carl Sagan
  • Harlan Ellison
  • Harry Harrison
  • Harry Turtledove
  • Isaac Asimov
  • Kurt Vonnegut
  • Robert Heinlein
  • Rudyard Kipling
  • The Brothers Strugatsky

Maser

  • Are you skeptical?
  • End of Media
  • Feed Your Mind
  • Gentoo
  • Michael Shermer strikes again
  • Tanenbaum
  • That's Some Catch
  • Those Pinko Commie Liberal Tree Huggers
  • Trips

Music

  • Cryptopsy
  • Death
  • Destruction
  • Immolation
  • Kataklysm
  • Morbid Angel
  • Muspellheim
  • My Audioscrobbler page
  • Nevermore
  • Nile
  • Slayer
  • Sodom
  • Vader

Kalends

February 2012
M T W T F S S
« Jan    
 12345
6789101112
13141516171819
20212223242526
272829  

His Due

Recent Entries

  • Castle Waiting
  • Flashman and the Angel of the Lord
  • Petey & Pussy
  • The Terrible Axe-Man of New Orleans
  • Temperance
  • Fifth Business
  • Portable dishwashers and the Residential Tenancy Agreement
  • Thriller 2
  • The October Country
  • Don Quixote

Recent Comments

  • Viren in Praise of Folly
  • Jandre Kroeze in Why the Salvation Army sucks
  • DELZELLR in Praise of Folly
  • sadbuttrue in Why the Salvation Army sucks
  • robert harvey in Why the Salvation Army sucks
  • Michael in Avast, Arachne!
  • Viren in The Histories
  • Daniel in The Histories
  • keel in SFU snow rage comic face
  • JD in Why the Salvation Army sucks
  • Random Selection of Posts

    • Dual monitors in Gentoo
    • New York Times Crossword Solution – Aug 15, 2007
    • There hath no greater love
    • The Aeneid
    • New York Times Crossword Answers – Oct 15, 2008
    • Britten & Brülightly
    • New York Times Crossword Answers – Nov 24, 2010
© 2008 The Inferno is proudly powered by WordPress
Theme designed by Roam2Rome