I want to store uploaded file in a directory C:\Inetpub\Users\Upload. c:\Inetpub is the home directory I have set, so it is pretty much HOME\Users\Upload.
However, when I use following commands, the file is stored in c:\Users\Uoload.
$upload_dir = "$HOME/Users/Upload";
$upload_filename = "$upload_dir/$filename";
if (! open UPLOADFILE, ">$upload_filename")
while ( <$upload_filehandle> )
My question is what am I doing wrong, and is there a predefined variable for home directory ?
Sounds like the "HOME" environment variable is not set.
If you just added the environment variable, you need to reboot Windows for it to take effect for an NT service like IIS. This is because NT services like IIS inherit their environment from services.exe, which does not get updated when you change system environment until you reboot.
If you did not just add the HOME environment variable -- then the problem is that the HOME variable does not exist on Windows. The Windows environment variables most similar in function to the *nix HOME variable are HOMEDRIVE and HOMEPATH.
There is a generic way to "update" the environment variables of an NT service WITHOUT rebooting Windows, but it is not guaranteed to work for all services. You can edit:
and add a String Registry value with a name/value same as the environment variable name/value, i.e. with the command:
REG.EXE add "HKLM\SYSTEM\CurrentControlSet\Services\IISADMIN\Parameters\Environment" /v HOME /t REG_SZ /d "C:\Inetpub" /f