473,698 Members | 2,225 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

moving file

44 New Member
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_uploade d_file($_FILES['uploaded']['tmp_name'],$destfile))
{
echo "copied succesfully to ".$destfile."<b r/>";
}
else
{
echo "failed to copy<br/>";
}
}
else
{
if(move_uploade d_file($_FILES['uploaded']['tmp_name'],$destfile))
{
echo "copied succesfully to ".$destfile."<b r/>";
}
else
{
echo "failed to copy<br/>";
}
}
//echo "The file".$_FILE['uploaded']['tmp_name']. " has been copied<br/> ";
}
else
{
if(move_uploade d_file($_FILES['uploaded']['tmp_name'],$destfile))
{
echo "copied succesfully to ".$destfile."<b r/>";
}
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_f ile(/home/FTP-shared/comp/06February2008/ZALC/olothe.rtf) [function.move-uploaded-file]: failed to open stream: Permission denied.
Feb 6 '08 #1
2 1434
Markus
6,050 Recognized Expert Expert
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_uploade d_file($_FILES['uploaded']['tmp_name'],$destfile))
{
echo "copied succesfully to ".$destfile."<b r/>";
}
else
{
echo "failed to copy<br/>";
}
}
else
{
if(move_uploade d_file($_FILES['uploaded']['tmp_name'],$destfile))
{
echo "copied succesfully to ".$destfile."<b r/>";
}
else
{
echo "failed to copy<br/>";
}
}
//echo "The file".$_FILE['uploaded']['tmp_name']. " has been copied<br/> ";
}
else
{
if(move_uploade d_file($_FILES['uploaded']['tmp_name'],$destfile))
{
echo "copied succesfully to ".$destfile."<b r/>";
}
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 New Member
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
8914
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? I am running UDB 8.2 on Linux and AIX. Thanks.
1
4735
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
3827
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 directory called: App_GlobalResources in my code i had :
11
2497
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 which size is 50MB and the second 30MB. Now we come to my problem. Is there possibility to swap this rows without using system memory (preferably in Unix/Linux)? Is there any function in C to do this?
2
38939
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 in the docs to create a new ibdata file on a bigger partition /disk2/var/mysql/ibdata2) and set that to autoextend instead. However I would like to reclaim the disk space on /var by moving the existing ibdata1 file to /disk2/var/mysql/ibdata1....
7
10820
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 doing a proof-of-concept on WCF whereby we have a Windows form client and a Server. Our server is a middle-tier that interfaces with our SQL 05 database server.
2
2877
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 /site/html/Pear.php /site/html/Sigma.php /site/html/Common.php /site/html/Quickform.php /site/html/Quickform/
4
1369
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, it seems that Visual Studio can no longer find them when I open a Button object (for example) and double click on the previously created event. On top of this, Visual Studio creates a new event that is blank. I know the program can 'see' my moved...
0
1848
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 the country. allows you to easily obtain no obligation moving quotes from local movers, long distance movers, international movers, auto transport, storage rentals and specialty movers. office movers, commercial moving, residential moving, movers...
0
1779
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 the country. allows you to easily obtain no obligation moving quotes from local movers, long distance movers, international movers, auto transport, storage rentals and specialty movers. office movers, commercial moving, residential moving, movers...
0
8603
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9157
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7723
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6518
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4366
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3045
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2328
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.