uploadform

Gestart doorRogier7 reacties44 weergaven

8 berichten · pagina 1 van 1

Rogier

Lid · Topicstarter

Berichten
6.485
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hey,

ik krijg mijn upload script maar niet werkend en ik vroeg me af wat ik fout doe... (en als je een betere manier weet mag je het ook zeggen smile
[COLOR= #0000BB]<?php 

$Error[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700];[/COLOR]

[COLOR= #0000BB]$target_path_thumb[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"../images/productfotos/thumbnails/"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$target_path_brochure[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"../images/productfotos/brochure/"[/COLOR][COLOR= #007700];[/COLOR]

[COLOR= #0000BB]$target_path_thumb[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$target_path_thumb[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/basename"]basename[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]thumbnail[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]name[/COLOR][COLOR= #007700]]);[/COLOR] 
[COLOR= #0000BB]$target_path_brochure[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$target_path_brochure[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/basename"]basename[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]brochure[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]name[/COLOR][COLOR= #007700]]);[/COLOR] 

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR][URL="http://www.php.net/move_uploaded_file"]move_uploaded_file[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]thumbnail[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]tmp_name[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #0000BB]$target_path_thumb[/COLOR][COLOR= #007700])) {[/COLOR]
    [COLOR= #0000BB]$Error[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"Het is niet gelukt om uw thumbnail-bestand up te loaden<br />"[/COLOR][COLOR= #007700];
}[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR][URL="http://www.php.net/move_uploaded_file"]move_uploaded_file[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]brochure[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]tmp_name[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #0000BB]$target_path_brochure[/COLOR][COLOR= #007700])) {[/COLOR]
    [COLOR= #0000BB]$Error[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"Het is niet gelukt om uw thumbnail-bestand up te loaden<br />"[/COLOR][COLOR= #007700];
}[/COLOR]

?>

<form  method="POST">                                                    

    <input type="hidden" name="MAX_FILE_SIZE" value="10000" />
    <strong>Upload brochure</strong><br />
    <input type="file" name="brochure" value=""><br /><br />

    <strong>Upload thumbnail</strong><br />
    <input type="file" name="thumbnail" value=""><br /><br />
                            
    <input type="submit" value="Voer wijzigen door.">
                        
</form>
0
Berichten
1.296
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Heb je de mappen we geupload ?

$target_path_thumb = "../images/productfotos/thumbnails/";
$target_path_brochure = "../images/productfotos/brochure/";


En anders moet je 1 map maken met het script en de mappen zoals ze er hier staan erin dan hoef je alleen dit nog te veranderen

$target_path_thumb = "images/productfotos/thumbnails/";
$target_path_brochure = "images/productfotos/brochure/";


Als het goed is yummie show anders de fout van het script ?
0
Rogier

Lid · Topicstarter

Berichten
6.485
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
De fout van het script is dat er niks gebeurd, jouw suggestie slaat nergens op...
0
Berichten
20.364
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
geen idee of dit werkt. Maar proberen kan geen kwaad.

[COLOR= #0000BB]<?php[/COLOR] 
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REQUEST_METHOD[/COLOR][COLOR= #007700]] ===[/COLOR] [COLOR= #DD0000]POST[/COLOR][COLOR= #007700])
{[/COLOR]
    
    [COLOR= #0000BB]$Error[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]();[/COLOR]
    
    [COLOR= #0000BB]$target_path_thumb[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"../images/productfotos/thumbnails/"[/COLOR][COLOR= #007700];[/COLOR]
    [COLOR= #0000BB]$target_path_brochure[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"../images/productfotos/brochure/"[/COLOR][COLOR= #007700];[/COLOR]

    [COLOR= #0000BB]$target_path_thumb[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$target_path_thumb[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/basename"]basename[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]thumbnail[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]name[/COLOR][COLOR= #007700]]);[/COLOR] 
    [COLOR= #0000BB]$target_path_brochure[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$target_path_brochure[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/basename"]basename[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]brochure[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]name[/COLOR][COLOR= #007700]]);[/COLOR] 

    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR][URL="http://www.php.net/move_uploaded_file"]move_uploaded_file[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]thumbnail[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]tmp_name[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #0000BB]$target_path_thumb[/COLOR][COLOR= #007700]))[/COLOR] 
        [COLOR= #0000BB]$Error[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]Het is niet gelukt om uw thumbnail-bestand up te loaden<br />[/COLOR][COLOR= #007700];[/COLOR]
        
    [URL="http://www.php.net/else"]else[/URL]
    [COLOR= #007700]{[/COLOR]
    
        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR][URL="http://www.php.net/move_uploaded_file"]move_uploaded_file[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]brochure[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]tmp_name[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #0000BB]$target_path_brochure[/COLOR][COLOR= #007700]))[/COLOR] 
            [COLOR= #0000BB]$Error[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]Het is niet gelukt om uw thumbnail-bestand up te loaden<br />[/COLOR][COLOR= #007700];
        
    }
    
}[/COLOR]
?>

<form method="post" enctype="multipart/form-data">                                       

    <input type="hidden" name="MAX_FILE_SIZE" value="10000" />
    <strong>Upload brochure</strong><br />
    <input type="file" name="brochure" /><br /><br />

    <strong>Upload thumbnail</strong><br />
    <input type="file" name="thumbnail" /><br /><br />
                            
    <input type="submit" value="Voer wijzigen door." />    
</form>
0
Rogier

Lid · Topicstarter

Berichten
6.485
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
// knip

Hier het systeem wat Jesse had gekopieert, kijk of jullie er iets mee kunnen smile.

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]brochure[/COLOR][COLOR= #007700]]) && ![/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]brochure[/COLOR][COLOR= #007700]])) 
    {[/COLOR]
        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]brochure[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]size[/COLOR][COLOR= #007700]] < ([/COLOR][COLOR= #0000BB]100000000[/COLOR] [COLOR= #007700]*[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700])) 
        {[/COLOR]
            [COLOR= #0000BB]$finfo[/COLOR] [COLOR= #007700]=[/COLOR] finfo_open[COLOR= #007700]([/COLOR]FILEINFO_MIME_TYPE[COLOR= #007700]);[/COLOR]
             
            [COLOR= #0000BB]$x[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/strrchr"]strrchr[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]brochure[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]name[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #DD0000]"."[/COLOR][COLOR= #007700]);[/COLOR]
                
            [COLOR= #0000BB]$brochure_naam[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/strtolower"]strtolower[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]brochure[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]tmp_name[/COLOR][COLOR= #007700]] .[/COLOR] [COLOR= #0000BB]$x[/COLOR][COLOR= #007700]);[/COLOR]
            [URL="http://www.php.net/move_uploaded_file"]move_uploaded_file[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]brochure[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]tmp_name[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #DD0000]"images/productfotos/brochures/"[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$brochure_naam[/COLOR][COLOR= #007700]);[/COLOR]
                
            [COLOR= #0000BB]$Brochure[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$brochure_naam[/COLOR][COLOR= #007700];
        }[/COLOR]
        [URL="http://www.php.net/else"]else[/URL]
        [COLOR= #007700]{[/COLOR]
            [COLOR= #0000BB]$Error[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]De brochure is te groot.[/COLOR][COLOR= #007700];
        }
    }[/COLOR]
    
    [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]thumbnail[/COLOR][COLOR= #007700]]) && ![/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]thumbnail[/COLOR][COLOR= #007700]])) 
    {[/COLOR]
        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]thumbnail[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]size[/COLOR][COLOR= #007700]] < ([/COLOR][COLOR= #0000BB]100000000[/COLOR] [COLOR= #007700]*[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700])) 
        {[/COLOR]
            [COLOR= #0000BB]$finfo[/COLOR] [COLOR= #007700]=[/COLOR] finfo_open[COLOR= #007700]([/COLOR]FILEINFO_MIME_TYPE[COLOR= #007700]);[/COLOR]
            
            [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR]finfo_file[COLOR= #007700]([/COLOR][COLOR= #0000BB]$finfo[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]thumbnail[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]tmp_name[/COLOR][COLOR= #007700]]) ==[/COLOR] [COLOR= #DD0000]"image/gif"[/COLOR] [COLOR= #007700]||[/COLOR] 
            finfo_file[COLOR= #007700]([/COLOR][COLOR= #0000BB]$finfo[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]thumbnail[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]tmp_name[/COLOR][COLOR= #007700]]) ==[/COLOR] [COLOR= #DD0000]"image/bmp"[/COLOR] [COLOR= #007700]||[/COLOR] 
            finfo_file[COLOR= #007700]([/COLOR][COLOR= #0000BB]$finfo[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]thumbnail[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]tmp_name[/COLOR][COLOR= #007700]]) ==[/COLOR] [COLOR= #DD0000]"image/png"[/COLOR] [COLOR= #007700]||[/COLOR] 
            finfo_file[COLOR= #007700]([/COLOR][COLOR= #0000BB]$finfo[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]thumbnail[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]tmp_name[/COLOR][COLOR= #007700]]) ==[/COLOR] [COLOR= #DD0000]"image/jpg"[/COLOR][COLOR= #007700]) 
            {[/COLOR]
                
                [COLOR= #0000BB]$thumb_naam[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/strtolower"]strtolower[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]thumbnail[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]tmp_name[/COLOR][COLOR= #007700]] .[/COLOR] [COLOR= #0000BB]$x[/COLOR][COLOR= #007700]);[/COLOR]
                [URL="http://www.php.net/move_uploaded_file"]move_uploaded_file[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]thumbnail[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]tmp_name[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #DD0000]"images/productfotos/brochures/"[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$thumb_naam[/COLOR][COLOR= #007700]);[/COLOR]
                
                [COLOR= #0000BB]$Thumbnail[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$thumbnaam[/COLOR][COLOR= #007700];
            }[/COLOR]
            [URL="http://www.php.net/else"]else[/URL]
            [COLOR= #007700]{[/COLOR]
                [COLOR= #0000BB]$Error[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]De thumbnail moet in gif, jpg, png of bmp worden geupload.<br />[/COLOR][COLOR= #007700];
            }
        }[/COLOR]
        [URL="http://www.php.net/else"]else[/URL]
        [COLOR= #007700]{[/COLOR]
            [COLOR= #0000BB]$Error[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]De Thumbnail is te groot.[/COLOR][COLOR= #007700];
        }
    }[/COLOR]


Wat gaat er fout: De upload wordt niet uitgevoerd, de variable xxxx_naam heeft geen waarde, waardoor in de database dus ook niks geplaats kan worden. (later in het script)
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Rogier schreef:
Ik had de hulp van XjesseX gekocht voor 1 pnt, toen heeft hij voor mij een standaard scriptje uitgezocht (en na menig aandringen heeft hij het uigelegd hoe het werkt, want daar had ik voor betaalt).

Maarja nu werkt dit dus ook niet en negeert Jesse me omdat het teveel werk werd... (hij heeft me überhaupt niet geholpen).

Hier het systeem wat Jesse had gekopieert, kijk of jullie er iets mee kunnen smile.
Quote:
if (isset($_FILES[brochure]) && !empty($_FILES[brochure]))
{
if($_FILES[brochure][size] < (100000000 * 1))
{
$finfo = finfo_open(FILEINFO_MIME_TYPE);

$x = strrchr($_FILES[brochure][name], ".");

$brochure_naam = strtolower($_FILES[brochure][tmp_name] . $x);
move_uploaded_file($_FILES[brochure][tmp_name], "images/productfotos/brochures/" . $brochure_naam);

$Brochure = $brochure_naam;
}
else
{
$Error .= De brochure is te groot.;
}
}

if (isset($_FILES[thumbnail]) && !empty($_FILES[thumbnail]))
{
if($_FILES[thumbnail][size] < (100000000 * 1))
{
$finfo = finfo_open(FILEINFO_MIME_TYPE);

if(finfo_file($finfo, $_FILES[thumbnail][tmp_name]) == "image/gif" ||
finfo_file($finfo, $_FILES[thumbnail][tmp_name]) == "image/bmp" ||
finfo_file($finfo, $_FILES[thumbnail][tmp_name]) == "image/png" ||
finfo_file($finfo, $_FILES[thumbnail][tmp_name]) == "image/jpg")
{

$thumb_naam = strtolower($_FILES[thumbnail][tmp_name] . $x);
move_uploaded_file($_FILES[thumbnail][tmp_name], "images/productfotos/brochures/" . $thumb_naam);

$Thumbnail = $thumbnaam;
}
else
{
$Error .= De thumbnail moet in gif, jpg, png of bmp worden geupload.
;
}
}
else
{
$Error .= De Thumbnail is te groot.;
}
}

Wat gaat er fout: De upload wordt niet uitgevoerd, de variable xxxx_naam heeft geen waarde, waardoor in de database dus ook niks geplaats kan worden. (later in het script)

Dat is geen standaard systeem? emo
En als je dan eens reageert op msn, maar nee.. Daar loop je me te negeren dus moet je ook niet zeuren? biggrin.
0
Rogier

Lid · Topicstarter

Berichten
6.485
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
// knip
0
Berichten
1.607
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Knipper de knip xd
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren