...

View Full Version : creating directory



romram
04-14-2004, 11:35 AM
I had used the code below to create a directory:



$username = strtolower($_SESSION["loginUsername"]);
$dir = "\\instructor\\" . $username;
if(!file_exists($dir)
mkdir($dir,0700);




before adding "\\instructor\\" . to the $dir varible it was working,
but because I want the folder to be created inside anothyer folder which is instructor folder I add this peice of code, but now it is not working..
Do somebody know what is the problem????? :confused:

Nightfire
04-14-2004, 12:42 PM
Slashes are the wrong way. You need forward slashes


$dir = "/instructor/" . $username;

romram
04-14-2004, 01:09 PM
I tried it but it didn't work! :(

Nightfire
04-14-2004, 01:30 PM
Is the instructer directory chmodded to 777?

romram
04-14-2004, 02:32 PM
Thankyou I solved the problem, but now I am facing another one, maybe you can help

I have page with name: ins_add_assig where I have a text field named "assigTitle" in the form tag I wrote the following:


<form name="form1" method="post" action="savefile.php?assig=$assigTitle" enctype="multipart/form-data">


in the page savefile.php I have the following code:



$username = strtolower($_SESSION["loginUsername"]);
$destination= "instructor/" . $username . "/". $assig . "/";
copy($HTTP_POST_FILES['uploadedFile']['tmp_name'],$destination);

:confused:

Nightfire
04-14-2004, 02:36 PM
$assig = $_GET['assig'];
$username = strtolower($_SESSION["loginUsername"]);
$destination= "instructor/" . $username . "/". $assig . "/";
copy($_FILES['uploadedFile']['tmp_name'],$destination);

romram
04-14-2004, 02:42 PM
I tried your answer and I print the path and this is what I got
"instructor/100/$assigTitle/ "
:confused:

Nightfire
04-14-2004, 05:10 PM
Change the form action to


<form name="form1" method="post" action="savefile.php?assig=<?php echo $_POST['assigTitle'] ?>" enctype="multipart/form-data">


Although I really don't see the point of you adding it to the url
Just have savefile.php as the action and then use the below


$assig = $_POST['assigTitle'];
//rest of your code here

romram
04-15-2004, 04:14 PM
Thankyou the problem is solved now



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum