View Full Version : php help

December 23rd, 2005, 11:40 AM
im trying to set up a php script that will allow users to upload files on to my server. everytime that i try to upload a file from another computer on to the server i get an error saying that i dont have permission to write to the specified directory. can anyone help me out on how i can change the php script to allow user uploads.
here is my simple php upload script:

$file_dir = "/directory path//";
foreach($_FILES as $file_name => $file_array) {
echo "path: ".$file_array['tmp_name']."<br />\n";
echo "name: ".$file_array['name']."<br />\n";
echo "type: ".$file_array['type']."<br />\n";
echo "size: ".$file_array['size']."<br />\n";

"$file_dir/$file_array[name]") or die("Couldn't copy");
echo "file was moved!<br /><br />";

thanks to anyone that can help me out.

December 23rd, 2005, 11:47 AM
You need to chmod 777 the dir before trying to upload files into it, but also check if safe mode is enabled on your server

December 23rd, 2005, 10:14 PM
im new to linux. how do i chmod 777 the dir. and how do i check if my server is in safe mode. id appreciate any help that you can give me.

December 23rd, 2005, 10:23 PM
well make a info.php and put this in it:


then hit it with a browser and search for safe_mode, see if it is on.

as for the folder, which FTP client do you use? in most you can right click on the directory and chmod or change permissions. there change it to 777 and it will be fine.

December 23rd, 2005, 11:10 PM
ok i chmod 777 the dir. my file uploader is now working thanks to you guyz.
but i checked and safe_mode is not enabled on my server. it is off. should it be enabled and if it should where can i change it. thank you

December 24th, 2005, 12:46 AM
no, it is much better and you have more control with it off. but with all such control, come responsibilities. just don't do anything too stupid, you'll be fine and your host won't get mad.

December 24th, 2005, 01:43 AM
ok thank you for the help. linux is a bit confusing. but i luv it.