Reputation: 10913
How to make WWW::Mechanize upload file under different file name?
I would like web server to see/record file name different from file name on my computer.
Upvotes: 3
Views: 1026
Reputation: 489
my $file = [
'filename-on-disk.txt', # The file you'd like to upload.
'filename-for-upload.txt', # The filename you'd like to give the web server.
'Content-type' => 'text/plain' # Any other flags you'd like to add go here.
];
$mech->post("http://example.com/upload.cgi", [
'upload' => $file
]);
Taken from: https://gist.github.com/gaurav/253111#file-file-upload-pl
Upvotes: 4
Reputation: 805
You can use a hard link:
link "file_name_on_your_computer","desired_new_name";
# Code to upload the newly created link
unlink "desired_new_name";
Notes
Upvotes: 0