473,405 Members | 2,187 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

moving file

44
hi friends
i am having a problem with creating folder within a directory.

$Tdate = date('dFY'); // first directory.
$_POST["courtAbr" //second directory
$Tdir ="/home/FTP-shared/comp"; //path where it suppose to create the directory


if(!file_exists($Tdir."/".$Tdate))
{
mkdir($Tdir."/".$Tdate);
echo"the directory ".$Tdir."/".$Tdate." has been created <br/>";
if(!file_exists($Tdir."/".$Tdate."/".$_POST["courtAbr"]))
{

mkdir($Tdir."/".$Tdate."/".$_POST["courtAbr"]);
echo"the directory ".$Tdir."/".$Tdate."/".$_POST["courtAbr"]." has been created <br/>";
if(move_uploaded_file($_FILES['uploaded']['tmp_name'],$destfile))
{
echo "copied succesfully to ".$destfile."<br/>";
}
else
{
echo "failed to copy<br/>";
}
}
else
{
if(move_uploaded_file($_FILES['uploaded']['tmp_name'],$destfile))
{
echo "copied succesfully to ".$destfile."<br/>";
}
else
{
echo "failed to copy<br/>";
}
}
//echo "The file".$_FILE['uploaded']['tmp_name']. " has been copied<br/> ";
}
else
{
if(move_uploaded_file($_FILES['uploaded']['tmp_name'],$destfile))
{
echo "copied succesfully to ".$destfile."<br/>";
}
else
{
echo "failed to copy<br/>";
}
}

}

so my problem is if i upload for the first time it work's,but when i try for the second time it refuse to create another folder based on $_POST["cortAbr"] upload files. and it display the message.

Warning: move_uploaded_file(/home/FTP-shared/comp/06February2008/ZALC/olothe.rtf) [function.move-uploaded-file]: failed to open stream: Permission denied.
Feb 6 '08 #1
2 1420
Markus
6,050 Expert 4TB
I cleaned your code up to make it easier for everyone to read(get yourself a decent editor, php designer is good):
[php]
$Tdate = date('dFY'); // first directory.
$_POST["courtAbr"] //second directory
$Tdir ="/home/FTP-shared/comp"; //path where it suppose to create the directory

if(!file_exists($Tdir."/".$Tdate))
{
mkdir($Tdir."/".$Tdate);
echo"the directory ".$Tdir."/".$Tdate." has been created <br/>";

if(!file_exists($Tdir."/".$Tdate."/".$_POST["courtAbr"]))
{
mkdir($Tdir."/".$Tdate."/".$_POST["courtAbr"]);
echo"the directory ".$Tdir."/".$Tdate."/".$_POST["courtAbr"]." has been created <br/>";

if(move_uploaded_file($_FILES['uploaded']['tmp_name'],$destfile))
{
echo "copied succesfully to ".$destfile."<br/>";
}
else
{
echo "failed to copy<br/>";
}
}
else
{
if(move_uploaded_file($_FILES['uploaded']['tmp_name'],$destfile))
{
echo "copied succesfully to ".$destfile."<br/>";
}
else
{
echo "failed to copy<br/>";
}
}
//echo "The file".$_FILE['uploaded']['tmp_name']. " has been copied<br/> ";
}
else
{
if(move_uploaded_file($_FILES['uploaded']['tmp_name'],$destfile))
{
echo "copied succesfully to ".$destfile."<br/>";
}
else
{
echo "failed to copy<br/>";
}
}
[/php]
Try chmod()'ing the directories when you create them:
[php]
mkdir("some/dir", 0755);
[/php]
Feb 6 '08 #2
ogo796
44
hi friends

basically on the above example i want to check if the directory exist if doesn't create directory and subdirectory and copy the files to the relevent subdirectory.

please if someone can help me i will be glad.
Feb 6 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Hemant Shah | last post by:
Folks, I need to move HOME directory of an instance to another directory. What is the best way of doing it? Is changing password file enough? or dies DB2 store this info in it's own config? ...
1
by: Arif | last post by:
Following are my text file(IndxItms.txt) contents: --------------------------------------------------- 0000 0 0002 52 0020 260 0045 312 0051 364 0087 416
5
by: Franck | last post by:
Hello, I've just moved to visual developper 2005 to do so, I also had to use the convert assistant. what it did; moving my file resx files that i had in a diresctory called resx to a new...
11
by: ulyses | last post by:
Let's assume I have following file: 2938929384902491233..... 923949919199191919112.... File contains INTs only. What is more they are huge. For example first row in file may contain integer...
2
by: fuzzybr80 | last post by:
I am using MySQL 5.0 with a number of innodb tables whose ibdata files are growing quite quickly and filling up the /var partition (file is /var/mysql/ibdata1). Earlier on I followed instructions...
7
by: =?Utf-8?B?TW9iaWxlTWFu?= | last post by:
Hello everyone: I am looking for everyone's thoughts on moving large amounts (actually, not very large, but large enough that I'm throwing exceptions using the default configurations). We're...
2
by: Paul | last post by:
I am moving an existing app written years ago to a new server. It uses Sigma Template 1.3 and Quickform 1.1.1 and PEAR.php,v 1.1.1.1 2004/02/16 The directory structure is like this: /site...
4
by: =?Utf-8?B?R1Q=?= | last post by:
I have a Form which has a great number of events. I thought I would organize the project by moving some of the code into multiple '.cs' files (since the Form.cs was getting huge). When I move them,...
0
by: linkswanted | last post by:
We are your trusted source. World Moving & Storage is bonded and licensed by the U.S. Department of Transportation and is one of the largest residential moving and corporate relocation company in...
0
by: linkswanted | last post by:
We are your trusted source. World Moving & Storage is bonded and licensed by the U.S. Department of Transportation and is one of the largest residential moving and corporate relocation company in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.