Page 1 of 1

Uploading with windows

PostPosted: 20. July 2006 16:47
by Katocan
Hey everyone, I'm trying to upload files using PHP and I'm using windows, I know it dosnt have CHMOD but is there anyway in which there are permissions I can change so that I can upload files to a certain folder or will I need to install Linux to be able to upload files via PHP.

Thanks :)

PostPosted: 20. July 2006 17:29
by Wiedmann
Where is your problem with file uploads?

You have read the PHP manual about "Handling file uploads" (Chapter 38)?

PostPosted: 20. July 2006 18:58
by Katocan
No I know I PHP quite well and its something to do with folder permissions as I can upload files when I used a server my friend provided which was Linux, but is there anyway I can get it to work on windows?

PostPosted: 20. July 2006 20:15
by Wiedmann
There is no difference in the file upload feature bettwen *nix and windows. (Problems with permissions are most seen on *nix.)

Without a sample script and/or error messages I can't help you.

PostPosted: 20. July 2006 21:35
by Katocan
Heres the code.
Code: Select all
if(!empty($_FILES["userfile"])) {
    $uploaddir = "/uploads/";

    if (move_uploaded_file($_FILES["userfile"]["tmp_name"], $uploaddir . $_FILES["userfile"]["name"])) {
           echo("file uploaded");
    } else {
        echo ("error!");

PostPosted: 20. July 2006 21:49
by Wiedmann
Error message you get in the brower (or what happens during upload)?

If you want debug a script, you should add
Code: Select all
ini_set('display_errors', '1');

after the line with "<?php".

Also the value of $_FILES is interesting here:
Code: Select all
echo var_dump($_FILES);

PostPosted: 20. July 2006 22:21
by Katocan
The error I get is
Warning: move_uploaded_file(/uploads/loading.gif) [function.move-uploaded-file]: failed to open stream: No such file or directory in C:\Program Files\xampp\htdocs\katocan\index.php on line 51

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\Program Files\xampp\tmp\php441.tmp' to '/uploads/loading.gif' in C:\Program Files\xampp\htdocs\katocan\index.php on line 51

Thanks for the help, it means alot![/code]

PostPosted: 20. July 2006 22:36
by Wiedmann
Warning: move_uploaded_file(/uploads/loading.gif) [function.move-uploaded-file]: failed to open stream: No such file or directory

This directory "/uploads/" exists?

PostPosted: 20. July 2006 22:45
by Katocan
Ye the directory exists

PostPosted: 20. July 2006 23:07
by Wiedmann
One test:
Please open a command shell (cmd.exe) and execute this command:
Code: Select all
dir \uploads\

(then copy 'n paste the result into your reply to this post)

PostPosted: 20. July 2006 23:17
by Katocan
The system cannot find the file specified.

C:\Program Files\xampp\htdocs\katocan>dir uploads
Volume in drive C has no label.
Volume Serial Number is DC7F-EF0E

Directory of C:\Program Files\xampp\htdocs\katocan\uploads

20/07/2006 04:50 <DIR> .
20/07/2006 04:50 <DIR> ..
0 File(s) 0 bytes
2 Dir(s) 14,347,763,712 bytes free

PostPosted: 20. July 2006 23:21
by Wiedmann

What did you think. Is:
"C:\Program Files\xampp\htdocs\katocan\uploads\"
is the same as:

(Simply count the chars from the two strings)

PostPosted: 20. July 2006 23:31
by Katocan
So...what shall I do?

PostPosted: 20. July 2006 23:32
by Katocan
Oh nevermind I got it, haha thanks so much for the help man!
I owe you one!