FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Why would chmod( ... ) fail with "No such file or directory"
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Why would chmod( ... ) fail with "No such file or directory" [message #173166 is a reply to message #173164] Fri, 25 March 2011 17:52 Go to previous messageGo to previous message
crankypuss is currently offline  crankypuss
Messages: 147
Registered: March 2011
Karma:
Senior Member
The Natural Philosopher <tnp(at)invalid(dot)invalid> wrote:

> Simon wrote:
>> Hi,
>>
>> I have some code that creates a temp file, writes to it and then calls
>> chmod(...) to make sure that the file has 0644 permissions.
>>
>> // -------------
>> // pseudo code
>> //
>> $tmpfname = 'xyx'; // come from another function.
>>
>> if (!($fd = @fopen($tmpfname, 'wb')))
>> {
>> return false;
>> }
>>
>> fwrite($fd, $data ); // the data comes from another function has well.
>> no warnings given.
>> fclose($fd); // no warnings given.
>> chmod( $tmpfname, 0644 ); <!-- error here with "No such file or directory"
>> // -------------
>>
>> The issue I have is that it works _sometimes_, in fact, 99% of the time
>> it works.
>> But from time to time the log reports that the file does not exist.
>>
>> But how it is possible, if the file opened successfully with fopen( ... )
>>
>> I wonder if the problem is partly because I am using @fopen(...) rather
>> than fopen(...), (I don't need to suppress the warnings).
>>
>> But in that case fwrite(...) and fclose(...) would also report
>> errors/warnings.
>>
>> Any suggestions as to why chmod(...), (and a subsequent rename(...) )
>> would sometimes not work.
>>
>
> I ran into some very strange issues like this a year back..my conclusion
> was that PHP caches file info and doesn't (always )flush to the OS until
> the session ends, if it can. So system calls within php referring to
> that file may fail.
>
> In my case it was a total failure of the mysql LOAD FILE command to find
> a PHP uploaded file until I had copy()-ed it to another filename...

The following might be useful background info:

http://www.php.net/manual/en/function.clearstatcache.php

--
no aluminum siding offers today
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Cannot send emails
Next Topic: website developers requirements
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 29 22:40:24 GMT 2024

Total time taken to generate the page: 0.04056 seconds