Здравейте, изведнъж ми се бъгна страницата пред която качвам клипчета...Преди си качвах без проблем, а сега изведнъж без да пипам нищо по страницата или просто пак си ви отваря да избера файл или ми изписва "Моля изберете клип."
Код:
<?
include ('auth_member.php');
include ('authconfig.php');
include ('check_member.php');
$user = $_COOKIE['LMUSERNAME'];
include ('header.php');
?>
<?
include ('config.php');
?>
<?php
$upload_dir = "video/";
//number of files to upload.
$num_files = 1;
//the file size in bytes.
$size_bytes = 26214400; //51200 bytes = 50KB.
//Extensions you want files uploaded limited to.
$limitedext = array(".flv");
$extension = flv;
//check if the directory exists or not.
if (!is_dir("$upload_dir")) {
die ("Error: The directory <b>($upload_dir)</b> doesn't exist");
}
//check if the directory is writable.
if (!is_writeable("$upload_dir")){
die ("Error: The directory <b>($upload_dir)</b> is NOT writable, Please CHMOD (777)");
}
//if the form has been submitted, then do the upload process
//infact, if you clicked on (Upload Now!) button.
if (isset($_POST['upload_form'])){
//do a loop for uploading files based on ($num_files) number of files.
for ($i = 1; $i <= $num_files; $i++) {
$files = array(
'rand' => str_shuffle(strtolower(substr(base64_encode(base64_encode(base64_encode(rand()))), 0, 10))));
//define variables to hold the values.
$names = time();
$new_file = $_FILES['file'.$i];
$codes = $files['rand'];
$file_name = $files['rand'].".".$extension;
//to remove spaces from file name we have to replace it with "_".
$file_name = str_replace(' ', '_', $file_name);
$file_tmp = $new_file['tmp_name'];
$file_size = $new_file['size'];
#-----------------------------------------------------------#
# this code will check if the files was selected or not. #
#-----------------------------------------------------------#
if (!is_uploaded_file($file_tmp)) {
//print error message and file number.
echo "<center>Моля изберете клип.</center><br>";
}else{
#-----------------------------------------------------------#
# this code will check file extension #
#-----------------------------------------------------------#
$ext = strrchr($file_name,'.');
if (!in_array(strtolower($ext),$limitedext)) {
echo "<center>Грешен формат на клипа.</center><br>";
}else{
#-----------------------------------------------------------#
# this code will check file size is correct #
#-----------------------------------------------------------#
if ($file_size > $size_bytes){
echo "<center>Клипа може да бъде максимум <b>". $size_bytes / 1024 ."</b> KB. </center><br>";
}else{
#-----------------------------------------------------------#
# this code check if file is Already EXISTS. #
#-----------------------------------------------------------#
if(file_exists($upload_dir.$file_name)){
echo "<center>Клипа вече съществува.</center><br>";
}else{
#-----------------------------------------------------------#
# this function will upload the files. :) ;) cool #
#-----------------------------------------------------------#
if (move_uploaded_file($file_tmp,$upload_dir.$file_name)) {
echo "<center>Клипа е качен успешно!<br><br>
<b>Клипа трябва да бъде одобрен от администратор, това ще стане в рамките на 24 часа.</b><br><br>
<b>Ако сте попълнили формата за качване некоректно, то клипа няма да бъде одобрен!</b></center>";
$name=$_POST['name'];
$text=$_POST['tag'];
$size=$file_size;
$description=$_POST['text'];
$category=$_POST['category'];
$date=date("l d, F Y H:i:s");
$ip = $_SERVER["REMOTE_ADDR"];
if(empty($description))
{
$description="Няма описание!";
}
$status = "ok";
if (strlen($tag) <3 ) { // проверка за попълнен текст
$status= "error";}
if (strlen($name) <3 ) { // проверка за попълнен текст
$status= "error";}
if($status=="ok"){
$connection = mysql_connect($dbhost, $dbusername, $dbpass);
$SelectedDB = mysql_select_db($dbname);
$posted = time();
$chars="SET CHARACTER SET cp1251";mysql_query($chars);
$query = mysql_query("INSERT clips (uploaded, name, code, description, tag, viewed, date, size, ip, category, status, posted) VALUES ('$user', '$name', '$codes', '$description', '$tag', '0', '$date', '$size', '$ip', '$category', '0','$posted')");
}
}else{
echo "<center>Клипа е качен успешно!</center>";
}#end of (move_uploaded_file).
}#end of (file_exists).
}#end of (file_size).
}#end of (limitedext).
}#end of (!is_uploaded_file).
}#end of (for loop).
# print back button.
////////////////////////////////////////////////////////////////////////////////
//else if the form didn't submitted then show it.
}else{
echo " <form method=\"post\" action=\"$_SERVER[PHP_SELF]\" name=\"Add\" enctype=\"multipart/form-data\">";
// show the file input field based on($num_files).
for ($i = 1; $i <= $num_files; $i++) {
echo 'HTML кода на страницата';
}
}
?>
<?
include ('footer.php');
?>