Jump to content

[SOLVED] Uploading flash files


mmarif4u

Recommended Posts

Hi,

I have a simple upload script, where i upload some images and flash files with swf extension.

But the problem is that swf files are not saving to the target directory, while images can. I am using Linux, the permission are fine on the folder. Saving to database the file name is also fine.

Everything is working, except saving to directory.

Any ideas about this.

 

Thanks

 

Link to comment
https://forums.phpfreaks.com/topic/131740-solved-uploading-flash-files/
Share on other sites

ok. this is the code.

 

$filename = $_FILES['image']['name'];
$filesize = $_FILES['image']['size'];
$filetype = $_FILES['image']['type'];
$file_tmp = $_FILES['image']['tmp_name'];
$file_err = $_FILES['image']['error'];
$file_ext = strrchr($filename, '.');
$file_ext = strtolower($file_ext);
//$strlenmyfile = strlen ($filename);


$target = "images/project/";
$target = $target . $myfile . $file_ext ;
$ok=1;

//This is our size condition (limit 350kb = 350000 bytes and 700kb = 700000 bytes)
if ($_FILES['image']['size'] > 700000)
{
	echo "<font color='red'>Error: Your file size is too large.</font><br>";
	$ok=0;
}

if($_FILES['image']['size'] < 1)
{
	echo "<font color='red'>Error: You tried to upload empty file.</font><br>";
	$ok=0;
}

$uploaded_type = $_FILES['image']['type'];

echo "<p>";
//echo "<br> file size =". $_FILES['image']['size'];
//echo "<br>uploaded_type = $uploaded_type";

echo "</p>";
//This is our limit file type condition
if ($uploaded_type =="text/php")
{
	echo "No PHP files<br>";
	$ok=0;
}
elseif ((!($uploaded_type=="image/jpg")) && (!($uploaded_type=="image/jpeg"))  && (!($uploaded_type=="image/gif")) && (!($uploaded_type=="application/x-shockwave-flash"))){
	echo "You may only upload JPG/GIF/SWF files.<br>You attempted to upload \"$uploaded_type\" type from $myfile<br>";
	$ok=0;
}



//Here we check that $ok was not set to 0 by an error
if ($ok==0)
{
	echo "<font color='red'>Error: Sorry your file was not uploaded.</font>";
}

//If everything is ok we try to upload it
else
{
	list($width, $height) = getimagesize($file_tmp);
	if($width > 750){ // = imagesx($filename);	
	echo "<center><strong><font class=\"red\">The image width is $width. Please keep it below</font> <font color='blue'>750</font>.</strong></center>";
}else{	
	if(move_uploaded_file($_FILES['image']['tmp_name'], $target)){
		$date=date('Y-m-d H:i:s');
		$sql="insert into proj_img(text,file,date)values('$text','$filename','$date')";
		$q=mysql_query($sql);
		echo "<center><strong><font class=\"red\">The file ".basename( $_FILES['uploadedfile']['name']). " has been uploaded</strong></center></font>";
	}else{
		echo "<font color='red'>Error: Sorry, there was a problem uploading your file.</font>";
	}
} 
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.