Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Velar Central File Submitter

by strredwolf (Chaplain)
on Sep 30, 2000 at 05:08 UTC ( #34720=sourcecode: print w/replies, xml ) Need Help??
Category: Web Stuff
Author/Contact Info Kelly "STrRedWolf" Price -- strredwolf
Description: The main code I use to send artwork to the Vixen Controled Library. Try it out as an example to code a HTTP POST w/multipart client. Oh, it does do authorization, but I've removed my password (so nyah!)

# Send2VCL - v0.2
use Socket;

# setup
$f=$ARGV[0]; $type="application/octet-stream";
$dir=$ARGV[1]; $dir="." unless($dir);
$type="image/gif" if($f=~/\.gif$/i);
$type="image/jpeg" if($f=~/\.jpg/i);
print STDERR "--- Sending $f to VCL/$dir\n";
$fi=$f; $fi =~ s#^.+/([^/]+)$#$1#;

# Connect
$iaddr   = inet_aton("") ||
    die "Can't resolve VCL: $!";
$paddr   = sockaddr_in(80, $iaddr);

$proto   = getprotobyname('tcp');
socket(SOCK, PF_INET, SOCK_STREAM, $proto)  ||
    die "Can't set up connection to VCL: $!";
connect(SOCK, $paddr)    ||
    die "Can't connect to VCL: $!";

# Autoflush everything.
$old=select(SOCK); $|=1; select($old);

# Print the request
print SOCK <<EOF;
POST /artist-admin/upload.cgi HTTP/1.0
User-Agent: RedWolf VCL Art Admin v0.2 (send2vcl)
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png
+, */*
Accept-Language: en
Accept-Charset: iso-8859-1,*,utf-8
Authorization: Basic nothing-really-here-really
Content-type: multipart/form-data; boundary=---VCLADMIN

open(OUT,">/tmp/vcl.$$") || die "/tmp/vcl.$$: $!";
print OUT "-----VCLADMIN\r\n";
print OUT "Content-Disposition: form-data; name=\"uploaddir\"\r\n\r\n"
print OUT "$dir\r\n";
print OUT "-----VCLADMIN\r\n";
print OUT "Content-Disposition: form-data; name=\"/Artists/Kelly-Price
+\"; filename=\"$fi\"\r\n";
print OUT "Content-type: $type\r\n\r\n";

open(IN,"<$f") || die "Can't open $f: $!";
    print OUT;
print OUT "\r\n-----VCLADMIN--\r\n";
$len=-s "/tmp/vcl.$$";

print SOCK "Content-Length: $len\r\n\r\n";
open(IN,"</tmp/vcl.$$") || die "Painfully!!! $!";
    print SOCK;


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://34720]
[atcroft]: .oO(Then there is the effect if a site changes their timezone, such as when the International Date Line was moved by the purchase of Alaska by the US from Russia in 1867, or several places (I cannot recall off-hand) that moved from one side of the Date
[atcroft]: Line to the other recently....)
[atcroft]: .oO(Then again, you also have to be careful if you had it to the database, and be aware of any assumptions it makes (such as SQLite assuming Gregorian calendar and a day of exactly 86400 seconds)...)

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2017-04-29 04:49 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (531 votes). Check out past polls.