Right Click Upload to Internet via Batch File

From TrivialBeing

The process of uploading one image or file used to be painful. I'd have to either open a browser and travel to an appropriate webform or open up my FTP client, log in and upload from there. Then I would have to find out its uploaded URL and paste it wherever I wanted the file to appear. So I spent a short while developing the simplest of batch file scripts to allow me to upload a file, to the server of my choice using only right click within Windows Explorer. I then added the ability to log these uploads with both local and online paths before finally copying the destination URL to the clipboard.

Contents

Batch File

e.g. saves this as ftp.bat

::---Start download.cmd---
@echo off

C:\copytoclipboard http://WWW.EXAMPLE.COM/DIRECTORY1/DIR2/%~n1%~x1

setlocal

::Variables
set f=%temp%\ftpc.txt
set i=PATH TO LOG FILE

::Compose ftp commands file
echo open FTP.EXAMPLE.COM>%f%
echo user USERNAME PASSWORD>>%f%
echo binary>>%f%

::Change to correct directory
echo cd DIRECTORY1>>%f%
echo cd DIR2>>%f%

::Upload to this directory
echo put %1>>%f%
echo bye>>%f%

:: Log Process to File "i"
echo Online: 	http://WWW.EXAMPLE.COM/DIRECTORY1/DIR2/%~n1%~x1 			Local: 	%1>>%i%

::Execute ftp command
::Use "-d" key for verbose output
ftp -n -d -s:%f%

::Cleanup
del /f /q %f%
endlocal
::---End download.cmd---

exit

%~n1 gives the filename for %1 %~x1 gives the file extension for %1

Copy to Clipboard

I used this website: http://mc-computing.com/Languages/CopyToClipboard.htm

And the file: http://mc-computing.com/code/CopyToClipboard.exe which I can confirm is safe.

I placed this file in C:\ simply for ease. Passing the generated URL in the batch file to this executable sends the data to the clipboard, for pasting into a webform, etc.

Send To

To enable right click > sendto > ftp for example, if you name the batch file ftp.bat, you need to copy the file you have created into the SendTo directory for your windows username, for instance: C:\Documents and Settings\USER\SendTo. This folder is hidden by default.

Security

It should be noted that your login details are available for all to see, so if you are using a shared computer this is not the safest of techniques to use.