我试图让这个非常基本的脚本将.swf文件上传到我的服务器而没有运气。 我尝试上传时收到无效文件错误。 .jpg,gifs,pngs都上传得很好。
我尝试改变一些东西,把swf放在jpg等等但没有快乐。
是否无法以这种方式上传swf文件?
非常感谢,非常感谢。`
文件名:
<?php
$allowedExts = array("gif", "jpeg", "jpg","swf","png");
$extension = end(explode(".", $_FILES["file"]["name"]));
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/jpg")
|| ($_FILES["file"]["type"] == "application/x-shockwave-flash/swf")
|| ($_FILES["file"]["type"] == "image/png"))
&& ($_FILES["file"]["size"] < 8388608)
&& 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";
}
?> `
答案 0 :(得分:0)
function addAdFields($post,$files){
//print_r( $files);
$allowedExts = array("gif", "jpeg", "jpg", "png" ,"tiff","tif","swf");
$fileType=$files["bannerType"]["type"];
$tmpName=$files["bannerType"]["tmp_name"];
$fileName=$files["bannerType"]["name"];
$imageName = mysql_real_escape_string($files["bannerType"]["name"]);
$imageData = mysql_real_escape_string(file_get_contents($files["bannerType"]["tmp_name"]));
$imageType = mysql_real_escape_string($files["bannerType"]["type"]);
list($width, $height, $type, $attr) = getimagesize($tmpName);
$dimArr= array($width, $height);
$temp = explode(".", $fileName);
$files["bannerType"]["name"];
$extension = end($temp);
$fileTmpName= mysql_real_escape_string($tmpName);
$curDate = "";
$ipadd = $_SERVER['REMOTE_ADDR'];
$camDetail=explode('_',$post['campaignType']);
$this -> tableName = "_ads";
$this -> fieldValues['campaignID'] = $camDetail[0];
$this -> fieldValues['campaignName'] =$camDetail[1];
$this -> fieldValues['adTitle'] = $post['adTitle'];
$this -> fieldValues['bannerID'] = $post['bannerType'];
if($_SESSION['bannerTyp']=='Placement')
{
$this -> fieldValues['uploadFileName'] = $post['placementText'];
}
else{
$this -> fieldValues['uploadFileName'] = $imageName;
$this -> fieldValues['uploadedFile'] = $imageData;
}
$this -> fieldValues['dimantation'] = json_encode($dimArr);
$this -> fieldValues['addDateTime'] = $curDate;
$this -> fieldValues['addIpAddress'] = $ipadd;
$this->insert();
//echo $this->query;
header('Location: main.html?action=add-ads&menuid=155');
}