Uploading files to your server while away from home - the easy way
Post ReplyUploading files to your server while away from home - the easy wayPosted: Thursday, August 18, 2011 [23:47:49] - 1
If you travel a lot (or not, does it matter?) sometimes you need to send some files (images, video, what have you) back home or to your server. All you have to have is a form on a web server to accept file upload and a small APpleScript application linked with Perl or PHP program to process files. Here is an AppleScript: tell application "Finder" end tell set scr_name to the quoted form of the POSIX path of my_folder_path set FileSent to do shell script ("echo " & quoted form of AllFiles & " | perl " & scr_name & "upload.cgi") display dialog "Files uploaded: " & "\n__________________\n" & FileSent and a corresponding Perl script located in the same folder as AppleScript application: my $list = <STDIN>; my $brids = 'Apple Safari Browser'; $list =~ s/\'//g; my @all = split(/\|/,$list); foreach $f (@all) { unless($f || $sent{$f}) {next;} $sent{$f}=1; if(-f "$f") { @fs = split(/\//,$f); $sndfile=$f; $result = `curl -F f=@"/$sndfile" -F fn=$fname1 -k http://YourServer.com/upload.file.cgi`; if($result =~ m/Upload Successful/) {print "$nof\. $fname1 uploaded\n";} } else {print "Can not find file $f\n";} } ## FOREACH END Script is not perfect but it does the job. Just save AppleScript as an application and place it in the same folder with Perl or PHP script and move the folder to your Applications. You can drop the AppleScript icon on a Dock for easy access. After a day on the field in a hotel just click on your Applescript program, select the folder with taken pictures and go for a nice dinner while your Mac will do the job of uploading files to your server for you. And you'll have a copy of all files in a safe place. |