Robis Posted April 5, 2004 Report Share Posted April 5, 2004 Sveiki! Mēģinu uztaisīt file upload php skriptu, bet viņš nedarbojas :( Varbūt kāds zin, kā var uztaisīt file upload skriptu - no web-lapas caur <input type="file"> tiek lādēts fails uz serverā atrodošā saita konkrētu direktoriju! Varbūt to var uztaisīt caur ftp, lai no web-lapas to varētu izdarīt???? Link to comment Share on other sites More sharing options...
Aleksejs Posted April 5, 2004 Report Share Posted April 5, 2004 Šeit viss ir pietiekami skaidri aprakstīts: http://lv.php.net/manual/en/features.file-upload.php Link to comment Share on other sites More sharing options...
Robis Posted April 5, 2004 Author Report Share Posted April 5, 2004 (edited) Izmantojot to metodi, kas tur aprakstīta, man parādās šāds warnings + vēl rāda, ka nav komanda nav izpildījusies sekmīgi! Warning: move_uploaded_file(): SAFE MODE Restriction in effect. The script whose uid is 564 is not allowed to access /var/www/html owned by uid 0 in /home/virtual/site/fst/var/www/html/site/upload.php on line 23 Array ( [upload_file] => Array ( [name] => Village.jpg [type] => image/pjpeg [tmp_name] => /tmp/phpWQHUDN [error] => 0 => 71915 ) ) Kas par lietu? :blink: Edited April 5, 2004 by Robis Link to comment Share on other sites More sharing options...
Ugga Posted April 5, 2004 Report Share Posted April 5, 2004 tas nozīmē to ka vajag mācīties Link to comment Share on other sites More sharing options...
Robis Posted April 5, 2004 Author Report Share Posted April 5, 2004 ok, gudriniek!!! Varbuut tu zini, kas tur par lietu??? Izmantoju visu kaa peec maaciibas graamatas (shoreiz gan oficiaalaa php manuaalja), bet neiet! Link to comment Share on other sites More sharing options...
Aleksejs Posted April 5, 2004 Report Share Posted April 5, 2004 tas nozīmē, ka tādēļ, ka ir ieslēgta SAFE MODE ir ierobežots, kādās direktorijās tu drīksti rakstīt. Pamēģini to upload direktoriju nomainīt no: /var/www/html/ uz: /home/virtual/site/fst/var/www/html/ Link to comment Share on other sites More sharing options...
Robis Posted April 5, 2004 Author Report Share Posted April 5, 2004 Njaa, paldies, bet es jau pirms tam to atklaaju uz izlaboju tagad viss iet! :D Man tikai interesee, kaa var nochekot vai tas fails, ko grib laadeet atbilst vienam no tiem dazhiem tipiem, ko driikst laadeet??? Link to comment Share on other sites More sharing options...
Aleksejs Posted April 5, 2004 Report Share Posted April 5, 2004 Kādiem tipiem tu domā? Tjipa, atļauti tikai teksta un PDF dokumenti un jāpārbauda, kāds tips ur uzuploadotajam failam? Visvienkāršākais būtu paskatīties paplašinājumu nosaukumam, ar kādu fails atsūtīts ($_FILES['userfile']['name']), bet pareizāk laikam ar mime_content_type() funkciju. Link to comment Share on other sites More sharing options...
Robis Posted April 5, 2004 Author Report Share Posted April 5, 2004 hmm... Es biju domaajis taa - ka var uploadot tikai bilzhu failus (.jpg, .jpeg, .png, .bmp - laikam tie ir tie...), tachu, cik saprotu ar mime_content_type() var paarbaudiit failu, kas ir uploadots? Bet vajadzetu taa, pirms juuzeris nospiezh OK, ja fails, ko grib suutiit neatbilst tam, neljaut vinjam nemaz uploadot!!! Kaa to vareetu? Link to comment Share on other sites More sharing options...
Aleksejs Posted April 5, 2004 Report Share Posted April 5, 2004 Nemācēšu pateikt, bet ņem vērā, ka šādi var ierobežot tikai godīgus lietotājus, tā teikt pret pašu stulbumu, jo viss, kas notiek uz klienta daļas ir lietotāja kontrolē. Link to comment Share on other sites More sharing options...
Robis Posted April 5, 2004 Author Report Share Posted April 5, 2004 ok, tad izmantojot mime_content_type() mees chekojam vai uploadotais fails pieder attieciigajiem mime tipiem, ja pieder, tad "succesful", ja nee, tad "failed" un izdzeesham no servera to failu, ja? (kaa to izdariit?) Un kur var dabuut tos mime tipus? Link to comment Share on other sites More sharing options...
Aleksejs Posted April 5, 2004 Report Share Posted April 5, 2004 ok, tad izmantojot mime_content_type() mees chekojam vai uploadotais fails pieder attieciigajiem mime tipiem, ja pieder, tad "succesful", ja nee, tad "failed" un izdzeesham no servera to failu, ja?Tieši tā.(kaa to izdariit?) Komanda unlink Un kur var dabuut tos mime tipus? Pamēģini uzuploadot attiecīgo tipu failus un uztaisīt echo tipam ko atgriež mime_content_type ;) Link to comment Share on other sites More sharing options...
Robis Posted April 5, 2004 Author Report Share Posted April 5, 2004 (edited) Koroch, es meegjinaaju unlink($_FILES['userfile']), bet vinjsh man paraadiija array to string conversion... Kas tieshi ir jaaunlinko? Un veel: mimetype man nedarbojas: function checkMime() { $mime_array = array('image/gif','image/jpeg','image/x-ms-bmp','image/x-xbitmap','image/x-xpixmap','image/x-png'); if (!function_exists ("mime_content_type")) { function mime_content_type ($file) { return exec ("file -bi " . escapeshellcmd($file)); } } $check_mime = mime_content_type($_FILES['userfile']['name']); if (in_array($check_mime, $mime_array)) { return TRUE; } else { return FALSE; } } Vienalga kādu failu es lādētu, vienmēr atgriež FALSE! Es mēģināju .jpg un .txt failus... Edited April 5, 2004 by Robis Link to comment Share on other sites More sharing options...
Robis Posted April 5, 2004 Author Report Share Posted April 5, 2004 Nu, tu gan Aleksej, noshaavi greizi! :D Tikko internetaa http://forums.devshed.com/archive/t-121358 izlasiiju, ka nevar noteikt mime_content_type(), ja tas fails ir ieksh $_FILES masiiva... Link to comment Share on other sites More sharing options...
Aleksejs Posted April 5, 2004 Report Share Posted April 5, 2004 Nevis $_FILES['userfile']['name'], bet gan $_FILES['userfile']['tmp_name'] ir jāpārbauda Link to comment Share on other sites More sharing options...
Recommended Posts