|
|
|
| Добрый день!
Подскажите пожалуста как переделать эти строки скрипта что бы можно было загужать файлы только аудио типа: .mp3 , .wav
$filetype = $_FILES['f']['type']; // получаем тип файла
if ($filetype != 'image/gif' && $filetype != 'image/jpeg' && $filetype != 'image/pjpeg')
{
die ("<center>
Разрешено загружать только файлы типов JPEG или GIF!<br>
<a href=\"#\" onclick=\"history.go(-1);return(false)\">Retour</a>
</center>");
}
|
Спасибо! | |
|
|
|
|
|
|
|
для: cccp
(22.01.2006 в 00:50)
| | if ($filetype != 'image/gif' && $filetype != 'image/jpeg' && $filetype != 'image/pjpeg')
не пробывал менятЬ!?? я не знаю но кажись тут сабака )) хотя я лол магу и ошибатся ) | |
|
|
|
|
|
|
|
для: cccp
(22.01.2006 в 00:50)
| |
<?
$extensions = array("mp3","wav");
$ext = substr(strrchr($_FILES['f']['tmp_name'], "."),1);
if(!in_array($ext,$extensions))
{
die ("<center>
Разрешено загружать только файлы типов JPEG или GIF!<br>
<a href=\"#\" onclick=\"history.go(-1);return(false)\">Retour</a>
</center>");
}
?>
|
| |
|
|
|
|
|
|
|
для: Евгений Петров
(22.01.2006 в 02:22)
| | Спасибо!
Я поставил так.
Но при загрузки файла .mp3 проиходит ошибка. Файл не загружается, как будто он запрещённый.
<?php
$dossier_cible = "../music/"; // zdes' put' k papke music
$dossier_cible_d = "../music/d/"; // zdes' put' k papke s opisanijami, d
$extensions = array("mp3","wav");
$ext = substr(strrchr($_FILES['f']['tmp_name'], "."),1);
if(isset($_FILES['f']) && isset($_POST['d']))
{
if(!in_array($ext,$extensions))
{
die ("<html><LINK rel=\"stylesheet\" href=\"../style.css\" type=\"text/css\" rel=\"stylesheet\">
<body>
<center><img src=../images/warning.gif><br>
Vous ne pouvez pas envoyer d'autres formats que .mp3 et .wav!<br>
<a href=\"#\" onclick=\"history.go(-1);return(false)\">retour</a>
</center></body>");
}
if (file_exists($dossier_cible.$_FILES['f']['name']))
{
die("<html><LINK rel=\"stylesheet\" href=\"../style.css\" type=\"text/css\" rel=\"stylesheet\">
<body>
<center><img src=../images/warning.gif>
<strong>Un erreur se produit !<br>Vérifier si vous avez remplis le formulaire<br>ou peut être le fichier au même nom existe déjà!</strong><br>
<a href=\"#\" onclick=\"history.go(-1);return(false)\">Retour</a>
</center>
</body>
</html>");
}
if(!move_uploaded_file($_FILES['f']['tmp_name'], $dossier_cible.str_replace(" ", "_", $_FILES['f']['name'])))
{
die("<html><LINK rel=\"stylesheet\" href=\"../style.css\" type=\"text/css\" rel=\"stylesheet\">
<body>
<center><img src=../images/warning.gif><br>
Un erreur se produit ! Vérifier l'autorisation d'écriture du dossier: $dossier_cible !<br>
<a href=\"#\" onclick=\"history.go(-1);return(false)\">Retour</a>
</center>
</body>
</html>");
}
$d = substr($_POST['d'], 0, 60);
// funkcija substr_replace() v dannom sluchae zamenjaet 3 poslednie simvola v imeni
// fajla na txt, t.e. sozdaem
// fajl s novym rasshireniem na osnove uzhe imejushhegosja imeni
// konkretnee - berem imja zagruzhennogo fajla, zamenjaem u nego rasshirenie i
// zapisyvaem v poluchivshijsja fajl
// opisanie, a sam fajl kladem v katalog $dossier_cible_d
$fp = fopen($dossier_cible_d.substr_replace(str_replace(" ", "_",$_FILES['f']['name']), "txt", -3, 3), "w");
fwrite($fp, stripslashes(htmlspecialchars($d)));
fclose($fp);
}
?>
|
| |
|
|
|
|
автор: Guestos (22.01.2006 в 04:13) |
|
|
для: cccp
(22.01.2006 в 02:42)
| |
<?php
if(eregi('^[a-z0-9_\.]+\.+(mp3|ogg|wav)+$', $fl_get)){ $type_file = "support"; }
?>
|
mozhet pomozhet | |
|
|
|
|
|
|
|
для: Guestos
(22.01.2006 в 04:13)
| | Спасибо!
Мне подсказали сделать таким методом.
$filetype = $_FILES['f']['type']; // poluchaem tip fajla . Razreshaem tol'ko audio fayli
if ($filetype != 'audio/mpeg' && $filetype != 'audio/x-wav' && $filetype != 'audio/midi')
|
Я ваш не пробовал но этот работает. | |
|
|
|