move file to new location

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
khhalid
Forum Newbie
Posts: 7
Joined: Tue Apr 20, 2010 4:45 pm

move file to new location

Post by khhalid »

Hi guys,
I want to move Excel file from one folder into another one. I am using following codes:
<?php
$file = "/uploaded/DMZ/newTest.txt";
$newlocation= "/uploaded/scanned/newTest.txt";
rename($file, $newlocation);
?>

Nothing happening when I execute the code.
Many thanks
User avatar
hypedupdawg
Forum Commoner
Posts: 74
Joined: Sat Apr 10, 2010 5:21 am

Re: move file to new location

Post by hypedupdawg »

I reccommend that you read this page: http://www.w3schools.com/php/func_filesystem_rename.asp, as well as looking at the php filesystem reference. It looks like this would be the best option for you - as long as you are uploading by the $_POST method.

Code: Select all

$file = "/uploaded/DMZ/newTest.txt";
$newlocation= "/uploaded/scanned/newTest.txt";
move_uploaded_file($file, $newlocation);
PS: It is better for everyone concerned if you post your code inside the php tags provided - click the "PHP Code" button when writing a post. That way it can be expanded, hidden, etc.
khhalid
Forum Newbie
Posts: 7
Joined: Tue Apr 20, 2010 4:45 pm

Re: move file to new location

Post by khhalid »

Thx guys, it was permission issue.

Thank you for your time,
Post Reply