Jump to content
php.lv forumi

Problema ar IF


GS_

Recommended Posts

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

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 by v3rb0
Link to comment
Share on other sites

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

×
×
  • Create New...