Jump to content

КАК СДЕЛАТЬ ЗАГРУЗКУ ВИДЕО С ПК


Recommended Posts

Вот код загрузки фото

	case "load_walls":
		NoAjaxQuery();
		$id = intval($_POST['id']);
		$image_tmp = $_FILES['uploadfile']['tmp_name'];
		$image_name = totranslit($_FILES['uploadfile']['name']);
		$image_rename = substr(md5($server_time+rand(1,100000)), 0, 20);
		$image_size = $_FILES['uploadfile']['size'];
		$type = end(explode(".", $image_name));
		
		$max_size = 1024 * 5000;
		
		if($image_size <= $max_size){
			$allowed_files = explode(', ', 'jpg, jpeg, jpe, png, gif');
			if(in_array(strtolower($type), $allowed_files)){
				$res_type = strtolower('.'.$type);	
				$upDir = ROOT_DIR.'/uploads/walls/'.$user_id.'/';
				
				if(!is_dir($upDir)){ 
					@mkdir($upDir, 0777);
					@chmod($upDir, 0777);
				}
				
				$rImg = $upDir.$image_rename.$res_type;
				
				if(move_uploaded_file($image_tmp, $rImg)){
				
					include_once ENGINE_DIR.'/classes/images.php';
					
					$tmb = new thumbnail($rImg);
					$tmb->size_auto(600);
					$tmb->jpeg_quality(95);
					$tmb->save($upDir.'o_'.$image_rename.$res_type);
					
					$tmb = new thumbnail($rImg);
					$tmb->size_auto('500x500');
					$tmb->jpeg_quality(95);
					$tmb->save($upDir.'ic_'.$user_id.'_'.$image_rename.$res_type);

					$tmb = new thumbnail($rImg);
					$tmb->size_auto(200, 1);
					$tmb->jpeg_quality(97);
					$tmb->save($rImg);

					die($user_id.'|'.$image_rename.$res_type);

				}
			}
		}else
			die('size');
	
		die();
	break;

может у кого нибудь есть пример на загрузку видео

Edited by Tisend
Link to comment
Share on other sites

Лёгкий пример

$allowedExts = array("mp4", "flv","jpg","JPEG");

       $extension = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);

 

       if ((($_FILES["file"]["type"] == "video/mp4")

 

       || ($_FILES["file"]["type"] == "video/flv")

       || ($_FILES["file"]["type"] == "image/jpg")

       || ($_FILES["file"]["type"] == "image/JPEG")

 

 

         )

 

          && ($_FILES["file"]["size"] > 2000000)

          && in_array($extension, $allowedExts))

 

         {

           if ($_FILES["file"]["error"] > 0)

         {

            echo "Return Code: " . $_FILES["file"]["error"] . "<br />";

          }

          else

         {

          echo "Upload: " . $_FILES["file"]["name"] . "<br />";

          echo "Type: " . $_FILES["file"]["type"] . "<br />";

           echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";

          echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";

 

        if (file_exists("upload/" . $_FILES["file"]["name"]))

       {

         echo $_FILES["file"]["name"] . " already exists. ";

        }

        else

      {

         move_uploaded_file($_FILES["file"]["tmp_name"],

        "upload/" . $_FILES["file"]["name"]);

        echo "Stored in: " . "upload/" . $_FILES["file"]["name"];

        }

       }

        }

         else

           {

        echo "Invalid file";

        }

    ?>

Link to comment
Share on other sites

1 час назад, Stark98 сказал:

Лёгкий пример

$allowedExts = array("mp4", "flv","jpg","JPEG");

       $extension = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);

  

       if ((($_FILES["file"]["type"] == "video/mp4")

 

        || ($_FILES["file"]["type"] == "video/flv")

       || ($_FILES["file"]["type"] == "image/jpg")

       || ($_FILES["file"]["type"] == "image/JPEG")

  

  

         )

 

          && ($_FILES["file"]["size"] > 2000000)

           && in_array($extension, $allowedExts))

  

         {

           if ($_FILES["file"]["error"] > 0)

         {

            echo "Return Code: " . $_FILES["file"]["error"] . "<br />";

          }

          else

         {

          echo "Upload: " . $_FILES["file"]["name"] . "<br />";

          echo "Type: " . $_FILES["file"]["type"] . "<br />";

           echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";

          echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";

 

        if (file_exists("upload/" . $_FILES["file"]["name"]))

       {

         echo $_FILES["file"]["name"] . " already exists. ";

        }

        else

      {

         move_uploaded_file($_FILES["file"]["tmp_name"],

        "upload/" . $_FILES["file"]["name"]);

        echo "Stored in: " . "upload/" . $_FILES["file"]["name"];

        }

       }

        }

         else

           {

        echo "Invalid file";

        }

     ?>

я кароче по своему сделал у меня получается то что он в папку пишет а вот в бд даные  не попадает 

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

×
×
  • Create New...