in reply to File Upload To Selected Directory
You basically want to do something like this:
and turn it into this:open (OUTFILE, ">$basedir/$fileName");
where $subdir is the subdirectory you wish to place your files under $basedir. If this directory is not guaranteed to exist, you will want to be sure to create it first:open (OUTFILE, ">$basedir/$subdir/$fileName");
If you're going multiple levels deep, with subdirectories under subdirectories, you'll need to (perhaps recursively) be sure each parent directory is created first, and only then try to save the file to it. Hope this helps.mkdir("$basedir/$subdir") unless -d "$basedir/$subdir"; open (OUTFILE, ">$basedir/$subdir/$fileName") or die "Could not open $basedir/$subdir/$fileName: $!";
|
|---|