我正在尝试使用一个简单的脚本,它允许我将不同类型的媒体上传到Web服务器,这些包括当前的视频和照片格式。我遇到的问题是当我尝试上传视频时,页面上的表单似乎无法提交。在我单击提交按钮时,页面会暂停一会儿,然后返回到正在显示的表单,就好像没有提交一样。
我试图增加$ max_file_size中的fileszie,这没有任何效果,它似乎没有达到使用它的位置。
我也在网上搜索过,它建议我使用代码顶部列出的“ini_set”功能来排除任何PHP表单提交问题 - 这些似乎没有效果。
<?php
ini_set('upload_max_filesize', '45M');
ini_set('post_max_size', '45M');
ini_set('max_input_time', 30000);
ini_set('memory_limit', '45M');
$file_types_array=array("avi", "JPG", "jpeg", "flv", "mpeg", "FLV");
// File Size maximum set in bytes
$max_file_size=35645847;
// Test directory created on the server to allow for uploads
// potential to direct to user spercific areas for secuirty concerns
$upload_dir="uploads\\";
// Holds Unix Time in seconds, used for a unique stamp per upload to
// avoud multiple images/videos having the same ID
$stamp = time();
// Unique User ID - 123 for testing
$UserID = 123;
/* If the form is not submitted, display the form */
if(!isset($_POST["submitted"])){
$form = "<form action='' method='post' enctype='multipart/form-data'>Upload files:<br /><input type='hidden' name='submitted' value='TRUE' id='".time()."'><input type='hidden' name='MAX_FILE_SIZE' value='".$max_file_size."'>";
$form .= "<input type='file' name='file[]'><br />";
$form .= "<input type='submit' value='Upload'><br />Valid file type(s): ";
// Displays the valid file types set in $file_types_array
for($x=0;$x<count($file_types_array);$x++){
if($x<count($file_types_array)-1){
$form .= $file_types_array[$x].", ";
}else{
$form .= $file_types_array[$x].".";
}
}
$form .= "</form>";
echo($form);
}else{
foreach($_FILES["file"]["error"] as $key => $value){
if($_FILES["file"]["name"][$key]!=""){
if($value==UPLOAD_ERR_OK){
$fileID = $_FILES["file"]["name"][$key];
$filename = explode(".", $_FILES["file"]["name"][$key]);
$filenameext = $filename[count($filename)-1];
// Checks for file extension
$file_ext_allow = FALSE;
for($x=0;$x<count($file_types_array);$x++){
if($filenameext==$file_types_array[$x]){
$file_ext_allow = TRUE;
}
}
if($file_ext_allow){
if($_FILES["file"]["size"][$key]<$max_file_size){
$fileWrite = $UserID."_".$stamp.".".$filenameext;
if(move_uploaded_file($_FILES["file"]["tmp_name"][$key], $upload_dir.$fileWrite)){
echo("File uploaded successfully.<br />");
}else{ // Catch for unprepared error
echo($fileID." was not successfully uploaded<br />");
}
}else{ // Catch for File Size too big
echo($fileID." was too big, not uploaded<br />");
}
}else{ // Catch for bad File Name
echo($fileID." had an invalid file extension, not uploaded<br />");
}
}else{ // Successful Output
echo($fileID." was not successfully uploaded<br />");
}
}
}
}
?>
对于这个主题的任何帮助都会非常感激,因为我已经盯着这段代码了一段时间了......
此致