GS_ Posted October 10, 2006 Report Share Posted October 10, 2006 Problema ar IF http://paste.php.lv/4548 Gribu lai atkariba no faila formata tiku izveleta direktorija kur saglabat failu, bet pasreiz kaut ari fails atbilst prasibam netiek izvelets neviens no mainigajiem. Errors tiek mests ara ka nav definets dest_name kuram jatiek definetam ieks mainigajiem. Link to comment Share on other sites More sharing options...
bubu Posted October 10, 2006 Report Share Posted October 10, 2006 No kuriens mums izzīst, kādas klases objekts ir $file un ko dara metode setValidExtensions? Ja jau tev saka, ka $dest_name, tad tas arī tāds ir - nedefinēts. Link to comment Share on other sites More sharing options...
GS_ Posted October 10, 2006 Author Report Share Posted October 10, 2006 No kuriens mums izzīst, kādas klases objekts ir $file un ko dara metode setValidExtensions?Ja jau tev saka, ka $dest_name, tad tas arī tāds ir - nedefinēts. $files = $upload->getFiles(); foreach($files as $file) Tas no pear setValidExtensions( array $exts, [string $mode = 'deny']) array $exts — File extensions to validate string $mode — The type of validation: 1) 'deny' Will deny only the supplied extensions 2) 'accept' Will accept only the supplied extensions as valid Bez mainigajiem viss normali strada, tik vajag lai audio faili butu cita direktorija. if ($file->isValid()) { $file->setValidExtensions(array('jpeg' ,'jpg' , 'gif', 'png' , 'mp3'), 'accept'); $file->setName("uniq"); $dest_name = $file->moveTo("images/"); if (PEAR::isError($dest_name)) { echo $dest_name->getMessage(); } $real = $file->getProp("real"); $position = strrpos($dest_name, "."); $ext=substr($dest_name, $position, 4); } elseif ($file->isMissing()) { echo "No file was provided."; } elseif ($file->isError()) { echo $file->errorMsg(); } Link to comment Share on other sites More sharing options...
Orion7 Posted October 11, 2006 Report Share Posted October 11, 2006 Tev $dest_name ir jānodefinē ārpus if cikla. Link to comment Share on other sites More sharing options...
bubu Posted October 11, 2006 Report Share Posted October 11, 2006 Vai tad? php taču neeksistē scope, tāpēc arī ifā definēts mainīgais būs redzams pēc ifa beigām. (btw if nav cikls. if ir nosacījuma kontroles struktūra) Link to comment Share on other sites More sharing options...
GS_ Posted October 11, 2006 Author Report Share Posted October 11, 2006 Ka jus ieteiktu so problemu atrisinat ? Link to comment Share on other sites More sharing options...
v3rb0 Posted October 11, 2006 Report Share Posted October 11, 2006 (edited) tur visu pārāk piņķerīgi raksti, viss ko tev vajag ir if($faila_extensions=='jpeg' || $faila_extensions=='jpg') { $directorija='jpg_bildes'; } else if ($faila_extensions=='gif') { $directorija='lēkājoši_ķiņķēziņi'; } lameriski, īsi un strādās Edited October 11, 2006 by v3rb0 Link to comment Share on other sites More sharing options...
GS_ Posted October 12, 2006 Author Report Share Posted October 12, 2006 Velviena prob. $handle=opendir("uploadimages"); while (($file = readdir($handle))!==false) { if ($file != "." && $file != "..") { $file_type = $_FILES['imgfile']['type']; $realname = $_FILES['imgfile']['name']; $file_size = $_FILES['imgfile']['size']; $file_tmp = $_FILES['imgfile']['tmp_name']; Ka pareizi nodefinet $file='imgfile' ? Izmeginaju daudz un dazadus variantus un neviens nestrada visu laiku Undefined index imgfile. Skripts ir prieks mass upload, versija kur 'imgfile' tiek dabuts ar formu viss normali strada... Meginaju ari taa $file_type = $_FILES[$file]['type']; Met ara Undefined index failanosaukums.ext Link to comment Share on other sites More sharing options...
Recommended Posts