spoks Posted March 11, 2004 Report Share Posted March 11, 2004 (edited) Vai ir iespeejams ieksh .htaccess vai kaa savaadaak noraadiit "savu" php upload temp diru? Edited March 11, 2004 by spoks Link to comment Share on other sites More sharing options...
Chickenz Posted March 11, 2004 Report Share Posted March 11, 2004 Cik nopratu tu gribi kautkaadu file upload uztaisiit, nafig tev noraadiit upload diru? Man kautkad sev bija jaauzcepina scripts - moška tev noder: <? if (($_SERVER['PHP_AUTH_USER']!="Chickenz")||($_SERVER['PHP_AUTH_PW']!="kaka")) { header('WWW-Authenticate: Basic realm="My Realm"'); header('HTTP/1.0 401 Unauthorized'); echo "<font color=\"red\" face=\"verdana\" size=\"2\">Sorry vecais, tu neesi admins!!!</font>";die;} else{ ?> <html> <head> <meta http-equiv="Content-Language" content="lv"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1257"> <LINK href="style.css" type="text/css" rel="stylesheet"> <title>Failu upload!</title> </head> <body> <table border="0" cellpadding="0" cellspacing="5" style="border-collapse: collapse" width="500" class="main_tab"> <tr><FORM ENCTYPE="multipart/form-data" ACTION="imageupload.php" METHOD="POST"> <td align="center" width="450" colspan="2"><?echo "<b>Sveiks {$_SERVER['PHP_AUTH_USER']}!!!</b>";?></td> </tr> <tr> <td align="center" width="100"> </td> <td align="center" width="400"> </td> </tr> <tr> <td align="center" width="100">Fails:</td> <td align="center" width="400"><INPUT TYPE="file" NAME="userfile" class="upload" size="20"> <INPUT TYPE="submit" VALUE="OK" class="b1"></td> </tr> <tr> <td align="center" width="450" colspan="2"> </td> </tr> <tr> <td align="center" width="450" colspan="2"> <?php extract($_POST, EXTR_SKIP); $dir = "file/"; $msize = 1024000; if (!isset($HTTP_POST_FILES['userfile'])) exit; if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) { if ($HTTP_POST_FILES['userfile']['size']>$msize){ echo "Fails ir pārāk liels<br>"; exit; } if (($HTTP_POST_FILES['userfile']['type']=="image/gif")|| ($HTTP_POST_FILES['userfile']['type']=="image/pjpeg")|| ($HTTP_POST_FILES['userfile']['type']=="image/jpeg")|| ($HTTP_POST_FILES['userfile']['type']=="image/bmp")|| ($HTTP_POST_FILES['userfile']['type']=="image/png")) { if (file_exists($dir . $HTTP_POST_FILES['userfile']['name'])){ $res = copy($HTTP_POST_FILES['userfile']['tmp_name'], $dir . $HTTP_POST_FILES['userfile']['name']); echo "<b>$realname</b> Šāds fails jau existē!!!";exit;} $res = copy($HTTP_POST_FILES['userfile']['tmp_name'], $dir . $HTTP_POST_FILES['userfile']['name']); if (!$res){ echo "<b>$realname</b>Failu nav iespējams aploudot!!! :(<br>";exit;} else{echo "<b>Fails veiksmīgi aploudoc!!!</b><br><br>"; } echo "Faila nosaukums: <b>".$HTTP_POST_FILES['userfile']['name']."</b><br>"; echo "Faila izmērs: <b>".round($HTTP_POST_FILES['userfile']['size']/1024) ." KB</b><br>"; echo "Faila tips:<b> ".$HTTP_POST_FILES['userfile']['type']."</b><br>"; } else { echo "Neatļauts faila tips<br>"; exit; }} ?> </td> </tr> <tr> <td align="center" width="450" colspan="2"><? echo "<br><b>Direktorijā $dir ir šādi faili:<br><br></b>"; $handle = opendir($dir); while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { echo "$file<br>"; } } closedir($handle); ?> </td> </tr> </table> </FORM> </body> </html> <?}?> Link to comment Share on other sites More sharing options...
Aleksejs Posted March 11, 2004 Report Share Posted March 11, 2004 2 Chickenz: Cik sapratu, tad viņam ir problēma ar to, ka neder norādītā temp direktorija uploadam (tā direktorija, kurā webserveris saglabā uploadotos failus, pirms php tos sāk apstrādāt). Tavā gadījumā $HTTP_POST_FILES['userfile']['tmp_name']... Link to comment Share on other sites More sharing options...
Kaklz Posted March 11, 2004 Report Share Posted March 11, 2004 upload_temp_dir ir viens no tiem uzstādījumiem, ko var mainīt tikai ar php.ini vai arī ar httpd.conf failiem.. tā kā ja pareizi sapratu jautājumu, tad diez vai izdosies vajadzīgais efekts. vēl var strīdēties par to, vai tas tiešām tev ir vajadzīgs ;) Link to comment Share on other sites More sharing options...
Venom Posted March 12, 2004 Report Share Posted March 12, 2004 Kaklz ir right. Sk. manuāli att. uz ini_set funkciju: upload_tmp_dir deafult:NULL mainīsanas tiesības: PHP_INI_SYSTEM PHP_INI_SYSTEM jeb 4: Entry can be set in php.ini or httpd.conf Link to comment Share on other sites More sharing options...
Recommended Posts