Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/257.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用php脚本将视频和图像上传到服务器_Php_Asp Classic - Fatal编程技术网

如何使用php脚本将视频和图像上传到服务器

如何使用php脚本将视频和图像上传到服务器,php,asp-classic,Php,Asp Classic,我希望我的客户端能够将图像从后端上传到服务器。请帮帮我。我还需要一个php脚本来上传视频。谢谢,这是我的代码,它不起作用 <?php // Configuration - Your Options $allowed_filetypes = array( '.doc', '.docx', '.xls', '.csv', ); # array('.jpg','.gif','.bmp','.doc'); // These will be the types o

我希望我的客户端能够将图像从后端上传到服务器。请帮帮我。我还需要一个php脚本来上传视频。谢谢,这是我的代码,它不起作用

<?php

// Configuration - Your Options
  $allowed_filetypes = array(

'.doc',

'.docx',

'.xls',

'.csv',

);  


  # array('.jpg','.gif','.bmp','.doc'); 

  // These will be the types of file that will pass the validation.
  $max_filesize = 1048567; // Maximum filesize in BYTES (currently 0.5MB).
  $upload_path = './files/'; // The place the files will be uploaded to (currently a 'files' directory).

 $filename = $_FILES['userfile']['name']; // Get the name of the file (including file extension).
 $ext = substr($filename, strpos($filename,'.'), strlen($filename)-1); // Get the extension from the filename.

 // Check if the filetype is allowed, if not DIE and inform the user.
 if(!in_array($ext,$allowed_filetypes))
  die('The file you attempted to upload is not allowed.');

 // Now check the filesize, if it is too large then DIE and inform the user.
 if(filesize($_FILES['userfile']['tmp_name']) > $max_filesize)
  die('The file you attempted to upload is too large.');

 // Check if we can upload to the specified path, if not DIE and inform the user.
 if(!is_writable($upload_path))
  die('You cannot upload to the specified directory.');

// change the name of the file  
$docid = substr(md5(uniqid()),30);

 // Upload the file to your specified path.
 if(move_uploaded_file($_FILES['userfile']['tmp_name'],$upload_path . $docid.$ext))
     echo 'Your file upload was successful, Thank you'; // It worked.
  else
     echo 'There was an error during the file upload.  Please try again.'; // It failed :(.

?>

您必须增加php.ini文件中视频上传的时间限制

max_execution_time = 3000 // 3000 or your requirements   
并在数组列表中添加允许的类型

 $allowed_filetypes =
  array('.doc','.docx','.xls','.csv','.flv');  

尝试上载文件时会收到什么错误消息?尝试在php文件顶部启用
error\u reporting
。您的html表单“多部分表单数据”是否已编码?是的,我的html表单支持“多部分表单数据”@Krister Andersson;'文件上载过程中出错。请再试一次。这是我在上传时遇到的错误。我不认为这一定是文件未上传的原因。这可能是一些事情,如:文件夹权限、文件扩展名、表单中没有enctype等。请问“表单中没有enctype”是什么意思?我已经知道文件扩展名,并且在上面的代码中指定了正确的文件夹