I got this file, but i got this error and i don't get why that happens.
Notice: Undefined index: uploaded in
C:\wamp\www\insert\insert2.php on line
25.
"
$ext = findexts($_FILES['uploaded']['name']) ;"
Code:
<?php
$connection = mysql_connect("localhost","root","");
if (!$connection) {
die("wrong connection: " . mysql_error());
}
$db_select = mysql_select_db("images",$connection);
if (!$db_select) {
die("error: " . mysql_error());
}
?>
<?php
function findexts ($filename)
{
$filename = strtolower($filename) ;
$exts = split("[/\\.]", $filename) ;
$n = count($exts)-1;
$exts = $exts[$n];
return $exts;
}
$ext = findexts($_FILES['uploaded']['name']) ; //here is the error
$ran = rand () ;
$ran2 = $ran.".";
$target = "C:/wamp/www/images/";
$target = $target . $ran2.$ext;
if(isset($_POST['submit']))
{
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "The file has been uploaded as ".$ran2.$ext;
}
else
{
echo "Sorry, there was a problem uploading your file.";
}
$rename = $ran2.$ext;
$query = "INSERT INTO images (name) VALUES ('$rename')";
mysql_query($query) or die('Error, query failed : ' . mysql_error());
}
?>
<html>
<body>
<form method="post" enctype="multipart/form-data" action="insert2.php">
<table width="350" border="0" cellpadding="1" cellspacing="1" class="box">
<tr>
<td width="246">
<input type="hidden" name="MAX_FILE_SIZE" value="2000000">
<input name="uploaded" type="file" id="uploaded">
</td>
<td width="80"><input name="submit" type="submit" class="box" id="upload" value=" Upload "></td>
</tr>
</table>
</form>
</body>
</html>
<?php
if(isset($connection)){
mysql_close($connection);
}
?>