PROBLEMS with PERMISSION & UPLOADS

Problems with the Mac OS X version of XAMPP, questions, comments, and anything related.

PROBLEMS with PERMISSION & UPLOADS

Postby ben88 » 26. February 2011 10:24

HI!
I'm new on mac and xampp...
i try to uploads file with this script:

1)form to choose file:
Code: Select all
<form enctype="multipart/form-data" action="up10b.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000">
Send this file: <input name="userfile" type="file">
<input type="submit" value="Send File">
</form>


2) php script to upload file:
Code: Select all
<?php

$uploaddir = 'htdocs';
$uploadfile = $_FILES['userfile']['name'];

if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
print "File is valid, and was successfully uploaded. ";
print "Here's some more debugging info:\n";
print_r($_FILES);
} else {
print "Possible file upload attack! Here's some debugging info:\n";
print_r($_FILES);
}
?>


It didn't work, so i set htdocs permission in this way:
sistema Read & write
admin Read & write
everyone Read & write

first question:
Is it ok? Is it insecure? I have to create a website for an exam at the university, just local, i don't have to put in online....

second question:
Files that i uploads go on my htdocs directory. But i would them go on a sub-directory htdocs/uploads. I try to change script:
$uploaddir = 'htdocs'; >> ON >> $uploaddir = 'htdocs/uploads';
but it doesn't work.... maybe i can't create a folder in htdocs? how can i do?

CAN ANYONE SPEND 5 MINUTES WITH ME??
please, i need help.... :cry:
ben88
 
Posts: 1
Joined: 26. February 2011 10:13

Re: PROBLEMS with PERMISSION & UPLOADS

Postby glitzi85 » 04. March 2011 23:08

Code: Select all
<?php

$uploadfile = sprintf("./uploads/%s', $_FILES['userfile']['name']);

if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
print "File is valid, and was successfully uploaded. ";
print "Here's some more debugging info:\n";
print_r($_FILES);
} else {
print "Possible file upload attack! Here's some debugging info:\n";
print_r($_FILES);
}
?>


Then restore the original permissions for htdocs and own the uploads directory by the Webserver user (check the httpd.conf for the user Apache runs as).

glitzi
User avatar
glitzi85
 
Posts: 1920
Joined: 05. March 2004 23:26
Location: Dahoim


Return to XAMPP for Mac OS X

Who is online

Users browsing this forum: No registered users and 3 guests