Does copy function creates a temporary file?
Moderator: General Moderators
-
stallingjohn
- Forum Newbie
- Posts: 6
- Joined: Mon Apr 23, 2007 2:16 am
Does copy function creates a temporary file?
I use copy function of php to copy a file from source folder to destination folder.
And I have found that destination folder contains new file with filename as "filename .txt".
Notice there is a space between "filename" and ".txt". I am thinking that it is a temporary file created by copy function of php.
If i'm correct how can I delete such temporary files????
please reply me as fast as possible
And I have found that destination folder contains new file with filename as "filename .txt".
Notice there is a space between "filename" and ".txt". I am thinking that it is a temporary file created by copy function of php.
If i'm correct how can I delete such temporary files????
please reply me as fast as possible
Re: Does copy function creates a temporary file?
How do you build the new file name in your script?
(to answer your question: No, I don't think it's a temporary file created by php or the os)
(to answer your question: No, I don't think it's a temporary file created by php or the os)
- maliskoleather
- Forum Contributor
- Posts: 155
- Joined: Tue May 15, 2007 2:19 am
- Contact:
-
stallingjohn
- Forum Newbie
- Posts: 6
- Joined: Mon Apr 23, 2007 2:16 am
Problem needs bit serious concerntation
feyd | Please use
And I have another script that reads "archive" folder. The script is as follows:
I print $fnames using following code:
when I echo like this it prints 2 files:
first is "file-name.txt" with link pointing to "archive/filename.txt" &
second is "file-name .txt" with link pointing to same "archive/filename.txt"
(note the space in second filename).
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
[b]The script I use to copy file is:[/b]Code: Select all
$shuffled_filename="done.txt";
$archive_filename="file-name.txt";
if (!copy("search/$shuffled_filename", "archive/$archive_filename"))
{
die("<br />Failed to copy shuffled file to archive file...");
}Code: Select all
$fnames=array();
$dir_path="archive";
if ($handle = opendir($dir_path))
{
while (false !== ($file = readdir($handle)))
{
$fnames[]=$file;
}
closedir($handle);
}Code: Select all
echo "<a href='archive/$fnames[$i]'>".$fnames[$i]."</a>";first is "file-name.txt" with link pointing to "archive/filename.txt" &
second is "file-name .txt" with link pointing to same "archive/filename.txt"
(note the space in second filename).
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
The error sounds like it occurring elsewhere. PHP doesn't just add characters to filenames... Try creating a different file and see if the same thing happens.
That was definitely volka, though I see the similarity. :-pmaliskoleather wrote:Its most likely that, as Fyed stated, that you have something wrong with your code.
- maliskoleather
- Forum Contributor
- Posts: 155
- Joined: Tue May 15, 2007 2:19 am
- Contact:
I dont see anything that would be causing the problem in this bit of code.
Do you have anything else that might be in your code that was involved in this? Old bits from when you were developing this function? Anything else that would write a file? I only ask, because im 99percent sure that PHP isnt just generating this extra file on its own, and for me it usually ends up being bits of rogue code that cause things like this.
I'd claim that I was drunk or something.. but its just not true
I guess that I need more caffeine.
Do you have anything else that might be in your code that was involved in this? Old bits from when you were developing this function? Anything else that would write a file? I only ask, because im 99percent sure that PHP isnt just generating this extra file on its own, and for me it usually ends up being bits of rogue code that cause things like this.
pshht. I didnt get the name right, or even spell the wrong name right lolsuperdezign wrote:That was definitely volka, though I see the similarity. :-p
I'd claim that I was drunk or something.. but its just not true
I guess that I need more caffeine.
-
stallingjohn
- Forum Newbie
- Posts: 6
- Joined: Mon Apr 23, 2007 2:16 am
Thanks for your answers
Thanks for your most valuable answers:
For solving above I used trim()
and then used preg_replace to replace all the whitespace , newline char, tab char to "blank" in the filename of the file
now the problem is solved.
For solving above I used trim()
and then used preg_replace to replace all the whitespace , newline char, tab char to "blank" in the filename of the file
now the problem is solved.