moving files

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
redhair
Forum Contributor
Posts: 300
Joined: Fri May 30, 2003 4:36 pm
Location: 53.23N-6.57E
Contact:

moving files

Post by redhair »

I have been given upload rights from my host, but the directory i have writing permissions to is one higher then the actual webspace.

I already am able to write files to it. using this script:

Code: Select all

<?php
// copy to this directory
$dir="/usr/local/apache/www/myacount/phpupl/";

 // copy the file to the server
if (isset($submit)){
       
if (!is_uploaded_file ($userfile)){

   echo "<b>$userfile_name</b> couldn't be copied !!";
}
// check whether it has been uploaded
if (is_uploaded_file ($userfile)){
  move_uploaded_file($userfile,$dir.$userfile_name) ;
  }
   echo "<b>$userfile_name</b> copied succesfully !!";
}
//note:extra security will added later, this is just an example.
?>
Now...how do i get the files from "/usr/local/apache/www/myacount/phpupl/" to "/usr/local/apache/www/myacount/html/upload" with php script.
(Since there is no move() command in php.)
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

what's wrong with move_uploaded_file()?
User avatar
redhair
Forum Contributor
Posts: 300
Joined: Fri May 30, 2003 4:36 pm
Location: 53.23N-6.57E
Contact:

Post by redhair »

i have only file writing permissions in the /phpupl/ folder..
There is nothing wrong with move_uploaded_file() it writes beautifully to that dir...but i dont want it there..
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

if you have no write permissions for another directory you can't write/copy/move files there, sorry...
User avatar
redhair
Forum Contributor
Posts: 300
Joined: Fri May 30, 2003 4:36 pm
Location: 53.23N-6.57E
Contact:

Post by redhair »

ok, thank you.
User avatar
CAN007
Forum Newbie
Posts: 9
Joined: Fri Jun 06, 2003 2:00 pm
Location: Toronto, Ontario, Canada

directory permissions

Post by CAN007 »

I found that I have to change the permission of creating a folder:

@mkdir($root.'/webftpupload/'.$create,0777);

However, Im not sure if this is completely accurate... but it works.
User avatar
redhair
Forum Contributor
Posts: 300
Joined: Fri May 30, 2003 4:36 pm
Location: 53.23N-6.57E
Contact:

Post by redhair »

I dropped the idear to move the files.
Now i'm trying to (unsuccesfull so far..) show the images that are in the folder outside www.
see post:
viewtopic.php?t=9429

eventualy things will work...
Post Reply