Jump to content

simple file upload works only with Firefox


mendoz

Recommended Posts

yope  ;)

 

Well...

 

This is a simple upload script which fails to work on Internet explorer.

May you tell me why?

 

<?php 

// we connect to the database
require("../conn.php");
// we get the id
$id = $_GET['id'];

// we get the file which has been uploaded ot not
$userfile = basename($_FILES['uploadedfile']['name']);

// we check if a file has been uploaded
if (!empty($userfile))
{
//This function separates the extension from the rest of the file name and returns it
function findexts ($filename)
{
	$filename = strtolower($filename) ;
	$exts = split("[/\\.]", $filename) ;
	$n = count($exts)-1;
	$exts = $exts[$n];
	return $exts;
}
//This applies the function to our file
$ext = findexts ($_FILES['uploadedfile']['name']) ;
//This just gives nanny5 etc
$ran2 = "nanny".$id.".";
//This assigns the subdirectory you want to save into... make sure it exists!
$target_path = "../images/nannies/videos/";
//This combines the directory, the random file name, and the extension
$target_path = $target_path . $ran2.$ext;
// if it does not succed the tell the user
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
	$uploadsql = "UPDATE `nannies` SET `vid`='".$ran2.$ext."' WHERE `id`=$id";
	mysql_query($uploadsql,$connection);
} else{
	echo "There was an error uploading the file, please try again!";
}
}
?>

<?php
$id = $_GET['id'];

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>TakeCareLinks.com - Control Panel</title>
<link rel="stylesheet" href="css.css" type="text/css" />
</head>

<body>
<center>
<br/><br/>Upload your video<br/>
<form enctype="multipart/form-data" action="vidprocess.php?id=<?php echo $id; ?>" method="POST">
<input name="uploadedfile" type="file" />
<input type="submit">
</center>
</body>
</html>

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.