Lunarpages Web Hosting Forum

Author Topic: Windows Server Issues  (Read 1780 times)

Offline fuzz

  • Intergalactic Superstar
  • *****
  • Posts: 188
    • http://www.fuzzmartin.com/
Windows Server Issues
« on: March 04, 2005, 10:34:05 PM »
This is completely an aside from my 5+ lunarpages hosting accounts, but I am stuck...  I am helping a buddy with his website which he has hosted on a Windows server.  Most of his sites are on linux servers, so I developed a program for him on my mac and had it all ready to go ... assuming, of course, that this program would be on a linux server as well.  I didn't learn that he was using a different server until I was ready to roll out the program.  (apparently he bartered out some free space on someone's nt server in exchange for some graphic design.)

Here is the problem... I have a php script that uploads a photo file to a directory.  Pretty simple right? It works on my computer and on my lunarpages account - but not on the windows server.  

I am under the impression that you cannot 'chmod' the normal way that you would on a linux apache server. The folder says 777 permissions in my coreFTP program - but it does not allow me to change anything.  

The error I am receiving is as follows:
<i>Warning: move_uploaded_file(images/cheif.jpg): failed to open stream: Permission denied in d:\wwwroot\selectapartments\SAP\upload.php on line 61

Warning: move_uploaded_file(): Unable to move 'C:\winnt\temp\php4106.tmp' to 'images/cheif.jpg' in d:\wwwroot\selectapartments\SAP\upload.php on line 61
There was a problem moving your file</i>

That comes from this script:
Code: [Select]
<!-- put all in upload.php file -->
<form action="upload.php" method="post" enctype="multipart/form-data">
Browse a File to Upload: <i>file must be 1MB or less. (1048576 bytes)</i><br>
<input type="file" name="filetoupload"><br>
<input type="hidden" name="MAX_FILE_SIZE" value="<?echo $size_bytes; ?>">
<br>
<input type="Submit" value="Upload File">
</form>

<?php
/*  Description -----------------------------------------------------
The Super Global Variable $_FILES is used in PHP 4.x.x.
$_FILES['upload'&#93;['size'&#93; ==> Get the Size of the File in Bytes.
$_FILES['upload'&#93;['tmp_name'&#93; ==> Returns the Temporary Name of the File.
$_FILES['upload'&#93;['name'&#93; ==> Returns the Actual Name of the File.
$_FILES['upload'&#93;['type'&#93; ==> Returns the Type of the File.

So if I filetoupload the file 'test.doc', the $_FILES['upload'&#93;['name'&#93;
would be 'phptut.doc' and $_FILES['upload'&#93;['type'&#93; would be 'application/msword'.
---------------------------------------------------------------------*/
// this is the upload dir where files will go.
//Don't remove the /
//Chmod it &#40;777&#41;
$upload_dir "images/";   //change to whatever you want.
// files less than 1MB
$size_bytes 1048576//bytes  will be uploaded
//check if the directory exist or not.
if &#40;!is_dir&#40;"$upload_dir"&#41;&#41; &#123;
    
die &#40;"The directory <b>&#40;$upload_dir&#41;</b> doesn't exist"&#41;;
&#125;
//check if the directory is writable.
if &#40;!is_writeable&#40;"$upload_dir"&#41;&#41;&#123;
        
die &#40;"The directory <b>&#40;$upload_dir&#41;</b> is NOT writable, Please Chmod &#40;777&#41;"&#41;;
&#125;

//Check first if a file has been selected
//is_filetoupload_file&#40;'filename'&#41; returns true if
//a file was filetoupload via HTTP POST. Returns false otherwise.
if &#40;is_uploaded_file&#40;$_FILES['filetoupload'&#93;['tmp_name'&#93;&#41;&#41;
&#123;

//Get the Size of the File
$size $_FILES['filetoupload'&#93;['size'&#93;;
//Make sure that $size is less than 1MB &#40;1000000 bytes&#41;
if &#40;$size > $size_bytes&#41;
&#123;
echo "File Too Large. Please try again.";
exit&
#40;&#41;;

&#125;
// $filename will hold the value of the file name submetted from the form.
$filename =  $_FILES['filetoupload'&#93;['name'&#93;;
// Check if file is Already EXISTS.
if&#40;file_exists&#40;$upload_dir.$filename&#41;&#41;&#123;
   
echo "Oops! The file named <b>$filename </b>already exists";
   exit&
#40;&#41;;
&#125;

//Move the File to the Directory of your choice
//move_filetoupload_file&#40;'filename','destination'&#41; Moves an filetoupload file to a new location.
if &#40;move_uploaded_file&#40;$_FILES['filetoupload'&#93;['tmp_name'&#93;,$upload_dir.$filename&#41;&#41; &#123;

//tell the user that the file has been filetoupload
echo "File &#40;<a href=$upload_dir$filename>$filename</a>&#41; uploaded!";
exit&
#40;&#41;;

&#125;
else
&
#123;
//Print error
echo "There was a problem moving your file";
exit&
#40;&#41;;

&#125;
&#125;

?>


I tried posting this on some other website somewhere because this isn't being hosted on my lunarpages account... but my brain hurts and lp always comes through to save the day.

thanks, btw, for your help. [/code]

Offline TranzNDance

  • Princess of Naboo
  • Berserker Poster
  • *****
  • Posts: 11567
    • Thu Tu's Blog
Windows Server Issues
« Reply #1 on: March 04, 2005, 10:41:17 PM »
:whip: :love: :whip: :love: :whip: :love:

Offline fuzz

  • Intergalactic Superstar
  • *****
  • Posts: 188
    • http://www.fuzzmartin.com/
Windows Server Issues
« Reply #2 on: March 04, 2005, 10:55:52 PM »
Thanks Thu!

The server is through an actual hosting company  - of which I won't have full admin privs  :wink:

Do you have any idea of what the privs should be set at for the images folder in the above file? I am going to have to ask the host to change the file settings for me - but I want to at least know what I specifically need before I start asking them to change things for me.

thanks again.