Hello!
Yes, well, I am started to make a upload fucntion.
question number one: I've made a if statement that should recognize what file extension the file has, if it has a .png extension it would be inserted into the picture database, and if it is a .txt file it will be inserted to another databas, but it is not worcking.
Can someone explain it to me?
my code:
$allowedExtensions = array("zip", "exe", "jpg","jpeg","JPG", "png", "gif", "txt", "odp");
function isAllowedExtension($fileName) {
global $allowedExtensions;
return in_array(end(explode(".", $fileName)), $allowedExtensions);
}
//Skjekker om bildet er tatt
$check = mysql_query("SELECT * FROM upload_file WHERE name='$name'");
if (mysql_num_rows($check)>=1)
die ("Username is taken!");
else {
if ($error > 0)
{
die("Error Uploading Image! Code $error.");
}
else
if($allowedExtensions=='png')
{ move_uploaded_file($temp,"../uploaded/pictures/".$name);
//setter inn dataen til databasen
$insert = mysql_query("INSERT INTO upload_file_png VALUES ('','$size','$name','20')") or die(mysql_error());
echo "Fil er lagret";
echo '<meta http-equiv="refresh" content="4; upload_file.php" />';
}
else {
2.
If i set a value to 20 in a database and every time someone is cliking on link like this : www.example.com/download?=name=123421.png and then the value will count down to 0
Thanks for answeres:)