Здравейте. Имам един файл, с който качвам през едно панелче снимки. Дублирах го и искам сега този код да качва .рар файлове, но нещо не мога да го направя май. Някой може ли да го прегледа и да го преправи и върне? Мерси.
Код:
<?
session_start();
if (isset($_SESSION['potrebitel']))
{
$potrebitel=$_SESSION['potrebitel'];
}
else
{
header('location:sessionform.php');
exit;
}
?>
<?
session_start();
if (isset($_SESSION['potrebitel']))
{
$potrebitel=$_SESSION['potrebitel'];
}
else
{
header('location:sessionform.php');
exit;
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<title> |Отаку България - Контролен панел| </title>
<link rel="icon" type="image/x-icon" href="http://otaku.bg/panel/img/Oz245Kl.png">
<link type="text/css" rel="stylesheet" href="style.css">
<style>
#box
{
background: #FFFFFF;
width: 600px;
height: 280px;
border: 1px solid #DBDBDB;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
}
</style>
</head>
<body>
<center>
<img src="http://otaku.bg/panel/img/7lODnQ3.png"><p style="font-size:24px;">Контролен панел</p>
<div id="box">
<br><img src="http://otaku.bg/panel/img/mVWcxoA.png"><br><a style="font-size:18px;">Качи субтитри</a><br /><br />
<form action="" method="post"
enctype="multipart/form-data">
<label for="file">Субтитри:</label>
<input type="file" name="file" id="file"><br />
<input type="submit" name="submit" value="Изпрати">
</form>
</div>
</center>
</body>
</html>
<?php
$allowedExts = array("rar");
$temp = explode(".", $_FILES["file"]["name"]);
$extension = end($temp);
$ime = $_FILES["file"]["name"];
if ((($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "rar")
|| ($_FILES["file"]["type"] == "image/pjpeg")
|| ($_FILES["file"]["type"] == "image/x-png")
|| ($_FILES["file"]["type"] == "image/png"))
&& ($_FILES["file"]["size"] < 1048576)
&& in_array($extension, $allowedExts)) {
if ($_FILES["file"]["error"] > 0) {
echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
} else {
echo "";
if (file_exists("../subtitles2/" . $_FILES["file"]["name"])) {
echo $_FILES["file"]["name"] . " already exists. ";
} else {
move_uploaded_file($_FILES["file"]["tmp_name"],
"../subtitles2/" . $_FILES["file"]["name"]);
echo "Субтитрите са качени успешно. <br><a href='$ime'>$ime</a>";
}
}
}
?>