[SOLVED] Copy() creates a blank copy

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
kaYak
Forum Commoner
Posts: 65
Joined: Mon Feb 02, 2004 2:43 pm
Location: USA

[SOLVED] Copy() creates a blank copy

Post by kaYak »

I'm trying to copy a file from one directory to another using php's copy function. It appears to copy it but it is a blank file (with no file size) but it has the right filename. I've tried using chmod to change the copied file's permissions but this hasn't seemed to help. Does anyone know what is going on?

Thanks,
Kyle
Last edited by kaYak on Tue Nov 29, 2005 8:08 pm, edited 1 time in total.
Deemo
Forum Contributor
Posts: 418
Joined: Sun Jan 18, 2004 11:48 am
Location: Washington DC

Post by Deemo »

can we see some code? i think that will help fix your problem
kaYak
Forum Commoner
Posts: 65
Joined: Mon Feb 02, 2004 2:43 pm
Location: USA

Post by kaYak »

Okay, here is some code:

Code: Select all

<?php

chmod("/1/file_111.txt", 0777);
copy("/1/file_111.txt","/2/file_111.txt");

?>
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

I cannot answer your question because I do not know what is causing it, but a comment at php.net/copy suggested an alternative
you can also try xcopy command by using Shell to move/copy files/folders from one place to another
here is the code:

Code: Select all

<?php
exec('xcopy c:\\myfolder d:\\myfolder /e/i', $a, $a1);
?>
by executing this command, it will move folder along with all contents to destination.
kaYak
Forum Commoner
Posts: 65
Joined: Mon Feb 02, 2004 2:43 pm
Location: USA

Post by kaYak »

Okay, this is very odd, for some reason it is working now. Perhaps it is because of the permissions change.
Post Reply