Reputation: 1506
I've tried to run this script: http://www.seaglass.com/file-upload-pl.html. in Apache. Since I'm running a win7 x64, I modified the script, so it goes:
#! C:\Perl64\bin\perl.exe -wT
instead of just
#! /usr/bin/perl
The page runs smoothly, but any uploading attempts fail with a Can't open /tmp/outfile for writing - No such file or directory
error.
I have created a /tmp/outfile
directory and a/tmp/outfile.txt
file.
I'm really new to Perl, and thus don't know what could be wrong.
Please advise.
Upvotes: 0
Views: 657
Reputation: 13551
Unix path components are delimited using forward slashes, not backslashes, drives cannot be seen explicitly in the path. Perl can handle /
as path separator on Windows, treating C:
as filesystem root. (Thanks, jimtut!) Therefore Unix path /tmp/outfile
translates to C:\tmp\outfile
on Windows. It is path to a (possibly non-existent) file, where the uploaded contents should be stored.
If you want to be really sure about portability of your code, use File::Spec module to build the paths. It allows avoiding explicitly writing path separator (/
on Unix, \
on Windows).
When using Windows-style paths, remember to double the \
when writing it into a double-quoted string. ("C:\\tmp\\outfile"
) The escaping issue is the same as in shell, PHP and many other languages…
Upvotes: 0
Reputation: 2393
/tmp/outfile is the output filename, not a directory name. Create C:\tmp, but remove C:\tmp\outfile if you really created that directory too.
Upvotes: 2