PHP Upload script image/gif

I need help with this Upload script.
I want too upload gif/moving pictures but with this script I can't.
I already searching on google how to make it work but I failed.

The script:
Quote<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);

$allowed = array('jpg', 'jpeg', 'gif', 'png');
$dir = 'gallery/NurdRage/';
$maxsize = 99999999999999999999999999;

if($_SERVER['REQUEST_METHOD'] == 'POST')
{
if(is_uploaded_file($_FILES['bestand']['tmp_name']))
{
$pathinfo = pathinfo($_FILES['bestand']['name']);
if(in_array($pathinfo['extension'], $allowed))
{
// De bestandsnaam van het uiteindelijke bestand
// Natuurlijk naar eigen wens aan te passen.
$file = $_FILES['bestand']['name'];

if($_FILES['bestand']['size'] < $maxsize)
{
if(move_uploaded_file($_FILES['bestand']['tmp_name'], $dir.$file))
{
$content[] = 'The file: '.$file.' been successfully uploaded..';
$content[] = 'The location of the file is: '.$dir.$file;
}
else
{
$errors[] = 'There was an error during upload';
}
}
else
{
if($maxsize == 0)
{
$errors[] = 'Uploading files is disabled';
}
else
{
$errors[] = 'The file is too large.';
}
}
}
else
{
$errors[] = 'This extension is not allowed!';
}
}
else
{
$errors[] = 'There is no file specified';
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<body>
<form action="#" method="post" id="upload" enctype="multipart/form-data">
<p>
<label class="field" for="bestand">File:</label>
<input type="file" name="bestand" id="bestand" />
<input type="submit" value="Upload" />
</p>
</form>

<?php
// Weergeven van meldingen uit het phpscript.
if(isset($errors))
{
echo '';
foreach($errors as $error);
{
echo ''.$error.'';
}
echo '';
}
elseif(isset($content))
{
foreach($content as $line)
{
echo $line;
}
}
?>


Thank you.
Comments
11
Try this one, it should work http://pastebin.com/uTpYYYyn . However it might need some correction for dat england language errors messages >D
File 3750a_1267017703_chicken-rape.gif is too big (maximum size is 99 MB)
-,- WhoooH!
Parent
Well, I couldn't see what was wrong that could give you an error.
So I just copy-pasted your code, and without editing anything I ran the script.
Of course, I didn't have your $dir.
So I've just modified the $dir to my localhost path, and voila it works perfectly.
ergo just check if your path ($dir) is correct. Because the coding does actually work.
It's a little easy, but nicely done ;)

2 things:
Use 'elseif{}' instead of 'else{ if{} }'
And outline your code, ffs.
All 4 extensions work with the upload...
Even the .gif (which would be extremely bizar if ONLY the .gif doesn't upload on your server. Then you should check the php.ini)

Good luck
Parent
Spamming the shit out of this:
But I think you didn't added your parent path, to the $dir?

$dir = 'gallery/NurdRage/';

EXAMPLE:
$dir = 'C:/gallery/NurdRage/'; (won't work if you have a server running that is NOT your pc (localhost), but I assume you know what I mean?)
Parent
Well got a server so then it needs to be "/var/www/vhosts/nurdrage.nl/nurdrage.nl/httpdocs/gallery/NurdRage"

But every extension works fine but gif not

And what do you mean with else and elseif? :Z

E; what i mean with gif pictures are pictures like this
image: 3750a_1267017703_chicken-rape
Parent
Its working now The only thing what I had to do is set the MB max size higher in my php.ini -.-
Parent
that's why I said: if it's only the gif, check your php.ini.

btw: which version of php are you using?
Parent
PHP Version: 5.4.4-14+deb7u2
Parent
Back to top