mkdir() and move_uploaded_file()
Posted: Tue Jan 17, 2006 10:24 am
hello everyone,
I am fairly new to these functions, I am trying to create a folder on my server using the mkdir function using an item name from the database which works fine, but i have trouble using move_uploaded_file() to then copy a php file from a form to the newly created folder, I have done some reading and i think the problem is because i have created the folder from an admin page , the user who created the folder user is 30 , which creates the problem.
How can i fix the problem , is it possible to create a folder from the admin page and then copy a file to the folder?
thanks for any help in advance. code i have pasted below.
vance
I am fairly new to these functions, I am trying to create a folder on my server using the mkdir function using an item name from the database which works fine, but i have trouble using move_uploaded_file() to then copy a php file from a form to the newly created folder, I have done some reading and i think the problem is because i have created the folder from an admin page , the user who created the folder user is 30 , which creates the problem.
How can i fix the problem , is it possible to create a folder from the admin page and then copy a file to the folder?
thanks for any help in advance. code i have pasted below.
vance
Code: Select all
function insert_template($id) {
$connection = mysql_connect($Host, $UserName, $PassWord);
mysql_select_db($DataBase);
$Room = mysql_query("select * from item_desc d,personal p,item i where d.item_id = i.item_id AND i.personal_id = p.personal_id AND i.personal_id = $id AND d.language_id = 1");
$room = mysql_fetch_assoc($Room);
if(is_dir("../personal/". $room["item_name"] ."/",0777) == false)
{
mkdir("../personal/". $room["item_name"] ."/");
chmod("../personal/". $room["item_name"] ."/",0777);
echo"". $room["item_name"] ."";
}
if(is_uploaded_file($_FILES["file"]["tmp_name"]))
{
$file_handle = fopen($_FILES["file"]["tmp_name"], "rb");
$file = addslashes(fread($file_handle, filesize($_FILES["file"]["tmp_name"])));
$Update = "Update personal set file = '" . $file . "' where personal_id = " . $room["personal_id"];
mysql_query($Update);
move_uploaded_file($_FILES["file"]["tmp_name"], "../personal/". $room["item_name"] ."/home_". $room["personal_id"] .".jpg");
echo"yes";
}
mysql_close($connection);
}