maarc93 Posted November 3, 2015 Report Share Posted November 3, 2015 Atverot saitu, parādās šis: file_put_contents(/tmp/1a827dc1b4e548626bb6c57ac4a97f7c): failed to open stream: No such file or directory iegooglējot sapratu, ka nav pieejas config un public mapei. Mēģināju noņemt read-only, bet nav iespējams. Kāds ir saskāries ar šo un tici galā? OS - Windows Quote Link to comment Share on other sites More sharing options...
briedis Posted November 3, 2015 Report Share Posted November 3, 2015 Nu skaties tad, kas sauc to file_put_contents un izlabo, lai nelieto /tmp/ mapi, bet gan lieto funkciju http://php.net/manual/en/function.sys-get-temp-dir.php Tad /tmp/ atgriezīsies korektais atkarībā no vides (win/nix) Quote Link to comment Share on other sites More sharing options...
maarc93 Posted November 3, 2015 Author Report Share Posted November 3, 2015 /** * Write the contents of a file. * * @param string $path * @param string $contents * @param bool $lock * @return int */ public function put($path, $contents, $lock = false) { return file_put_contents($path, $contents, $lock ? LOCK_EX : 0); } šī funkcija izraisa problēmas. $path vietā ieliku funkciju sys_get_temp_dir() un rāda to pašu - file_put_contents(C:\Windows\TEMP): failed to open stream: Permission denied Quote Link to comment Share on other sites More sharing options...
ieleja Posted November 3, 2015 Report Share Posted November 3, 2015 manuprāt Windows 'Users' grupai nav tiesību rakstīt sistēmas 'TEMP' folderī Quote Link to comment Share on other sites More sharing options...
jurchiks Posted November 3, 2015 Report Share Posted November 3, 2015 (edited) T.i. viņš varēja uzstādīt (w)amp setupu + Laravel, bet nevar piekļūt TEMP folderim? Neticu. Tad jau viņam gandrīz neviena softa instalācija neietu. Edited November 3, 2015 by jurchiks Quote Link to comment Share on other sites More sharing options...
maarc93 Posted November 3, 2015 Author Report Share Posted November 3, 2015 man ir cits laravel projekts uzlikts uz virtual host un tas iet ar visu read only Quote Link to comment Share on other sites More sharing options...
Kasspars Posted November 3, 2015 Report Share Posted November 3, 2015 (edited) file_put_contents(/tmp/1a827dc1b4e548626bb6c57ac4a97f7c): Man uz windows visi faila vārdi sākas ar c:/ vai d:/.... varbūt tu šajā gadījumā padod linuxīgu faila vārdu un tāpēc tev izmet error No such file or directory sys_get_temp_dir() -> DIR! Direktorija Skatamies php manuālī funkciju file_put_contents. Redzam, ka pirmais parametrs ir FILENAME! int file_put_contents ( string $filename , mixed $data [, int $flags = 0 [, resource $context ]] ) -> FILENAME! Bet tu funkcijai file_put_contents padod direktoriju Vispār visiem jaunajiem censoņiem iesaku iemācīties lokalizēt problēmu! Tik pat labi "nedarbojas laravel" vietā varēji rakstīt "nedarbojas dators" vai "nedarbojas zemeslode" Edited November 3, 2015 by Kasspars Quote Link to comment Share on other sites More sharing options...
maarc93 Posted November 3, 2015 Author Report Share Posted November 3, 2015 ja es pareizi saprotu, tad, ja nemaina konfigurāciju, visam vajadzētu strādāt uz linux'a, jo tad uz diska ir tmp mape. Kur konfigurācijā jāmaina tmp mapes atrašanos windows gadījumā? Quote Link to comment Share on other sites More sharing options...
briedis Posted November 3, 2015 Report Share Posted November 3, 2015 Principā vēl labāk būtu izmantot šo funkciju, lai ģenerētu pagaidu faila vārdu: $tmpfname = tempnam("/tmp", "FOO"); Quote Link to comment Share on other sites More sharing options...
ieleja Posted November 4, 2015 Report Share Posted November 4, 2015 bet nevar piekļūt TEMP folderim? lietotājam ir savs, nesistēmas TEMP folderis, parasti \Users\lietotājs\AppData\Local\Temp Quote Link to comment Share on other sites More sharing options...
jurchiks Posted November 4, 2015 Report Share Posted November 4, 2015 (edited) Man echo sys_get_temp_dir(); izvada "C:\Users\{myusername}\AppData\Local\Temp". Un man ir admin acc. Cik es saprotu, šī funkcija čeko environment variabli TEMP. Ja tas nav definēts aktīvajam lietotājam, tad izmanto sistēmas TEMP. Edited November 4, 2015 by jurchiks Quote Link to comment Share on other sites More sharing options...
Kasspars Posted November 4, 2015 Report Share Posted November 4, 2015 Jūs jokojat!? :D Ir jāpadod faila vārds nevis direktorijas vārds! file_put_contents nevar rakstīt direktorijā Quote Link to comment Share on other sites More sharing options...
briedis Posted November 4, 2015 Report Share Posted November 4, 2015 Jūs jokojat!? :D Ir jāpadod faila vārds nevis direktorijas vārds! file_put_contents nevar rakstīt direktorijā Palasi augstāk, es jau saku, ka jālieto tempnam, kas atgriež dir + vārdu Quote Link to comment Share on other sites More sharing options...
jurchiks Posted November 4, 2015 Report Share Posted November 4, 2015 (edited) Tas tad visiem ir skaidrs. Oriģinālajā postā autors arī padeva full path incl. filename, problēma tikai tajā, ka viņš padod hardcoded linux path uz windows mašīnas. Vai arī viņam ir sačakarēts TEMP environment variablis. Vai arī tas ir domāts relative path, in which case you dun goof'd, autor. Edited November 4, 2015 by jurchiks Quote Link to comment Share on other sites More sharing options...
maarc93 Posted November 4, 2015 Author Report Share Posted November 4, 2015 (edited) Man sys_get_temp_dir() izvada C:\Windows\TEMP. bet dīvaini, ka man ir cits laravel projekts, kurā šāda problēma nav. Un ja ievadu manuāli $path vietā "C:\Users\{myusername}\AppData\Local\Temp", tad rāda - file_put_contents(C:\Users\Marcis\AppData\Local\Temp): failed to open stream: Permission denied pamēģināju uz linux palaist lapu, bet rāda 500 server error. /var/log/apache2/error.log rāda šo: [Wed Nov 04 14:30:22.191672 2015] [:error] [pid 3606] [client 127.0.0.1:50649] PHP Fatal error: Uncaught exception 'UnexpectedValueException' with message 'The stream or file "/var/www/projektaNos/storage/logs/laravel-2015-11-04.log" could not be opened: failed to open stream: Permission denied' in /var/www/projektaNos/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:87\nStack trace:\n#0 /var/www/projektaNos/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php(88): Monolog\\Handler\\StreamHandler->write(Array)\n#1 /var/www/projektaNos/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\\Handler\\RotatingFileHandler->write(Array)\n#2 /var/www/projektaNos/vendor/monolog/monolog/src/Monolog/Logger.php(289): Monolog\\Handler\\AbstractProcessingHandler->handle(Array)\n#3 /var/www/projektaNos/vendor/monolog/monolog/src/Monolog/Logger.php(565): Monolog\\Logger->addRecord(400, Object(Symfony\\Component\\Debug\\Exception\\FatalErrorException), Array)\n#4 /var/www/projektaNos/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(50): Monolog\\Logger->error(Ob in /var/www/projektaNos/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 87 Edited November 4, 2015 by maarc93 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.