Article View: pl.comp.lang.php
Article #220473Re: Rename + open_basedir restriction
From: Ja
Date: Tue, 08 Sep 2009 12:14
Date: Tue, 08 Sep 2009 12:14
38 lines
1854 bytes
1854 bytes
Lemat pisze:
> Ja wrote:
>
>> Witam!
>>
>> Mam taki skrypt:
>>
>> <?
>> $string="";
>> $fileCount=0;
>> $filePath=$PATH.'/home/a68848/public_html/g/';
>> $dir = opendir($filePath);
>> while ($file = readdir($dir)) {
>> if (eregi("\.zip",$file)) {
>> $string .= "$file";
>> $fileCount++;
>> }
>> }
>> if ($fileCount > 0) {
>> $search = array('%5B', '%5D', '%20');
>> $replace = array('[', ']', ' ');
>> $subject = $string;
>>
>> $new_name = str_replace($search, $replace, $subject);
>> rename($string, $new_name);
>> }
>> ?>
>>
>> Skrypt zwraca błąd "Warning: rename() [function.rename]: open_basedir
>> restriction in effect...", ale jak miejsce $string, $new_name wstawię
>> gołe nazwy plików (bez żadnych ścieżek to nazwy się zmieniają.
>> Wie ktoś, gdzie tkwi błąd?
>
> nie ma żadnego błędu, jest to prawidłowe zachowanie PHP
>
To w takim razie co zmienić, żeby w pętli zmienić we wszystkich nazwach
plików (w jednym katalogu) znaki: %5B na [ , %5D na ] , a $20 na spacje?
Technical Details
Message-ID:
<h85hrv$lel$1@news.onet.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!news.onet.pl!not-for-mailReferences:
<h85gt8$j3a$1@news.onet.pl> <h85h64$fsp$1@atlantis.news.neostrada.pl>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!news.onet.pl!not-for-mail From: Ja <fm24@poczta.onet.pl> Newsgroups: pl.comp.lang.php Subject: Re: Rename + open_basedir restriction Date: Tue, 08 Sep 2009 14:14:46 +0200 Organization: http://onet.pl Lines: 38 Message-ID: <h85hrv$lel$1@news.onet.pl> References: <h85gt8$j3a$1@news.onet.pl> <h85h64$fsp$1@atlantis.news.neostrada.pl> NNTP-Posting-Host: 188.33.33.235 Mime-Version: 1.0 X-Trace: news.onet.pl 1252412096 21973 188.33.33.235 (8 Sep 2009 12:14:56 GMT) X-Complaints-To: niusy@onet.pl NNTP-Posting-Date: Tue, 8 Sep 2009 12:14:56 +0000 (UTC) User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) In-Reply-To: <h85h64$fsp$1@atlantis.news.neostrada.pl> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit