php help
- Started
- Last post
- 7 Responses
- drzoom
I'm quite new to php, but I think I am going mad: all I want to do is copy one file from one folder to another (at the moment only locally). but instead it deletes the file just before it wants to copy it - which of course results in the file not existing anymore to copy.
here is the bit of script:
$bol=file_exists($file);
//here the file is still there
if($bol){
//here it is gone!!!
if(copy($file, "$path_to_upload_dir/$file_name...
- smoothblend0
looks around for mike..
>.<
- drzoom0
?
- meph5040
what OS is your server ?
also I often find it easier to use the
`cp $path/$file $newpath/file`but that is on *nix based boxs
some other things to check
-file permissions the program maybe able to see the file but not copy it
may want to chmod("0777") then change permissions back after move-make sure you aren't out of space alot time if the server is out of space then when it working with files during a move it will copy them to a buffer and then reallocate the old space to the system then try to allocate space in the new location. if there is no space, it will just dump the buffer.
-lastly make sure there isn't a copy in the new directory on some systems instead of over writing the file it will cause an error.
if you need more help with this let me know
- mike0
your slashes are killing you...
from
$sOldPath."/".$sFile
to
$sNewPath."/".$sFile
the / is literal, so escape it.
- drzoom0
thanks mike, that worked!
...just another problem, I thought copy would actually copy the file, but it seems to just move it. Is there any way of copying it?
- drzoom0
anyone?
- mike0
copy should copy the files just fine, are you sure you aren't unlinking the file or anything like that?