Jump to content
php.lv forumi

failu upload


eT`

Recommended Posts

Tātad izveidoju vienkāršu failu augšupielādes f-ju.

Man vajadzētu, lai pārbauda failu paplašinājumu/us.

Izveidoju, ka pārbauda vienu paplašinājumu, bet kā ir ar vairākiem?

Man katru reizi veidot savu elseif :/

vai ir kāda iespēja kā visus paplašinājumus ievietot masīvā un tad pārbaudīt?

mans pārbaudes kods:

 

function findexts ($filename)
{
$filename = strtolower($filename) ;
$exts = split("[/\\.]", $filename) ;
$n = count($exts)-1;
$exts = $exts[$n];
return $exts;
}

$ext = findexts ($_FILES['uploaded']['name']);

if ($ext != rar)
{
echo "STFU!";
}

Link to comment
Share on other sites

Un ir vienkāršāki (lasi - pareizāki, kas strādā arī tad, ja failam nav nosaukuma) veidi kā tikt pie paplašinājuma

$ext = pathinfo($_FILES['uploaded']['name'], PATHINFO_EXTENSION);

 

Tiešām?

php.net:

The following associative array elements are returned: dirname, basename, extension (if any), and filename.

 

If options is used, this function will return a string if not all elements are requested.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...