Jump to content

UPLOADING FILES ... works on debugger not when browsed on IIS


captainoats

Recommended Posts

I just started learning PHP a couple of weeks ago.

 

Right now I just wanna create a HTML page that uploads a GIF file onto my webserver...well for now just the local server IIS.

 

I thought my code was wrong but maybe its not. I think the problem lies within my IIS settings and the Inetpub/wwwroot directory.

 

I Tried uploading to the Inetpub directory but not onto the "wwwroot" folder. It worked.  So I knew my code had nothing to do with it. 

 

I have a PHPed installed which I sometimes use to program PHP.  Well I tried opening the file there and then running the program using its debugger.  I browsed for a file and BOOM!!...success...went straight into the inetpub/wwwroot

 

Just like it should.

 

But when I browse the same html file on IIS...I get 2 lines of warning messages ..

 

Warning: move_uploaded_file(/Inetpub/wwwroot/adImages/iwasmoved.gif) [function.move-uploaded-file]: failed to open stream: Permission denied in C:\Inetpub\wwwroot\uploader.php on line 4

 

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\WINDOWS\TEMP\phpF7.tmp' to '/Inetpub/wwwroot/adImages/iwasmoved.gif' in C:\Inetpub\wwwroot\uploader.php on line 4

 

I dont get those when running the webpage on the phped server.

 

Here is my UPLOAD_TMP_DIR on PHP.ini found on /WINDOWS.

 

upload_tmp_dir = "C:/Inetpub/wwwroot"

 

and here is the PHP script that is used for uploading..very simple

 

<?php

 

move_uploaded_file ($_FILES['uploadedfile'] ['tmp_name'],

      "/Inetpub/wwwroot/adImages/{$_FILES['uploadedfile'] ['name']}")

 

?>

 

i dont need the 'if statement' telling me its uploaded just yet..

 

How do I fix this...maybe I have to change something in my IIS properties or something like that...Like I said...The code works but not when using IIS to browse the page..Its weird..

 

Please explain in a way that noob would understand..well sort of noobie...hehe.. THANKS...

 

 

 

here is my code, it works fine under IIS

 

$target_path = "uploads/";

$target_path = $target_path . basename($_FILES['uploadedfile']['name']);

$r = move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path);

 

If you should ask what the difference is, look at $target_path, instead of putting "/Inetpub/wwwroot/" I only put the folder (uploads) where i want the uploaded file to go, what the problem is, i think php was looking for a folder named Inetpub/wwwroot/ inside your root directory.

 

Hope this helps.

Everything works fine ....Using this code..

 

move_uploaded_file ($_FILES['uploadedfile'] ['tmp_name'],

      "/Inetpub/Scripts/{$_FILES['uploadedfile'] ['name']}")

 

This works fine..I could successfully upload into Inetpub/Scripts directory..or any folder for that matter.  The problem is when I want to upload to Inetpub/wwwroot...

 

It always fails.  So sad...

 

move_uploaded_file ($_FILES['uploadedfile'] ['tmp_name'],

      "/Inetpub/wwwroot/{$_FILES['uploadedfile'] ['name']}")

 

It will always return these Warning Messages

Warning: move_uploaded_file(/Inetpub/wwwroot/iwasmoved.gif) [function.move-uploaded-file]: failed to open stream: Permission denied in C:\Inetpub\wwwroot\uploader.php on line 4

 

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\WINDOWS\TEMP\php56.tmp' to '/Inetpub/wwwroot/iwasmoved.gif' in C:\Inetpub\wwwroot\uploader.php on line 4

 

So the directory iwas found I guess coz It didnt warn me that no such directory exists.  And if i change "wwwroot" into another folder inside Inetpub...like "Scripts" it works like a charm.

 

Something is wrong with my "wwwroot".  Could someone tell me what it is and how to fix it..

 

Im using Dreamweaver to run this code and preview the browser.  I also Use IIS to browse the webpage...

 

 

Again...When I use another program like PHPED to run the webpage...It uploads the file successfully..files are uploaded to "wwwroot" unlike when using dreamweaver to view the page and IIS .

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.