Jump to content
php.lv forumi

Recommended Posts

Posted

Nevaru saprast

<?php
$name = $_FILES['photo']['name'];
$tmp_name = $_FILES['photo']['tmp_name'];
$size = $_FILES['photo']['size'];
$type = $_FILES['photo']['type'];
$ext = explode(".", strtolower($name));
$ext = substr($name, strrpos($name, '.')+1);
$allowed = array("image/jpg", "image/jpeg", "image/gif", "image/png");

if(!in_array($type, $allowed)) {
 echo $ext;
}else{
echo $name."<br>";
echo $tmp_name."<br>";
echo $size."<br>";
echo $type."<br>";
echo $ext."";
}
?>

 

kad izvēlos bilžu formātu viss ir ok.. parāda informāciju ko prasu. izvēlos txt formātu parāda tikai faila formātu, bet kad izvēlos mp3 failu man rāda notices par 2,3,4,5 rindiņu! Kapēc???

Posted (edited)

Un kādus notice tad rāda?

 

..varu derēt, ka rāda undefined index notice, jo fails netika ielādēts, jo max upload size ir uzstādīts mazāks par tipiska mp3 izmēru.

 

Ko darīt? Pirms ķeries pie faila apstrādes, pārliecinies, vai tas vispār ir ielādēts.

Edited by briedis
Posted

hmm, bet man ir norādīts max file size

<form method="post" action="process/image.process.php" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="83886080">
<input type="file" name="photo">
<input type="submit" value="Ok">
</form>

 

un php.ini man arī ir norādīts daudz lielāks file size limits nekā mp3 fails

Posted

pag, kā tad to var pārbaudīt?

$_FILES['fails']['error'] -> tiek nodoti visi parametri. par potencialo kļudu,

0 nav kļuda , parējos kļudas indeksus meklē pats ( norāda kāpēc neizdevās uplādot .. )

Posted (edited)

GreyWolf, potenciāls undefined index, ja fails netika ielādēts.

Kāpēc?? indekss jau padodas šā vai tā ar POST ... idejiski būs konkrēts kļūdas numurs,

fails par lielu, fails netika saglabāts uz servera utt... šeit sīkāk

edit: vispār vienmēr ir vēlams pārbaudīt vai pie faila ielādes nav kļūda, šādi var viegli izķert ja fails ir pārāk liels, vismaz var userim atmest atpakaļ sakarīgu error mesāgi ...

Edited by Grey_Wolf

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...