HTML interesse |
|
Dat is wellicht wel t gemakkelijkste, onderstaand script is mijn uploadscript, hoe zou dat er dan uit komen te zien om de extensie om te zetten naar lower case? Tevens wilde ik het script nog eens aanpassen zodat er enkel .jpg bestanden geplaatst kunnen worden.
<?php
$config['map'] = "FILES/big/"; //aanpassen
function upload_size( $size, $maxm="200000" ) { //maxm wijzigen
if( $size > $maxm ) {
error( 'Je file is te groot!' );
}
}
function error( $error, $exit=TRUE ) {
echo $error;
if( $exit == TRUE ) {
exit;
}
}
function bestaat_al( $naam ) {
if( file_exists( $naam ) ) {
error( 'De file-naam bestaat al/Of je hebt niets ingevuld!' );
}
}
if( isset($_POST['uploaden']) ) {
upload_size( $_FILES['upload']['size'] );
bestaat_al( $config['map'] . $_FILES['upload']['name'] );
move_uploaded_file( $_FILES['upload']['tmp_name'], $config['map'] . $_FILES['upload']['name'] );
echo 'Je plaatje is geupload!<br>
<a href="FILES/big/'.$_FILES['upload']['name'].'">Zie je file</a><br>
';
} else {
?>
<form method="post" enctype="multipart/form-data" name="upload">
<table>
<tr>
<td>File:</td>
<td><input type="file" name="upload" id="upload"></td>
</tr>
<tr>
<td>Upload:</td>
<td><input type="submit" name="uploaden" value="uploaden"></td>
</tr>
</table>
</form>
<?
}
?>
<?php $config['map'] = "FILES/big/"; //aanpassen function upload_size( $size, $maxm="200000" ) { //maxm wijzigen if( $size > $maxm ) { error( 'Je file is te groot!' ); } } function error( $error, $exit=TRUE ) { if( $exit == TRUE ) { } } function bestaat_al( $naam ) { error( 'De file-naam bestaat al/Of je hebt niets ingevuld!' ); } } if( isset($_POST['uploaden']) ) { upload_size( $_FILES['upload']['size'] ); bestaat_al( $config['map'] . $_FILES['upload']['name'] ); move_uploaded_file( $_FILES['upload']['tmp_name'], $config['map'] . $_FILES['upload']['name'] ); echo 'Je plaatje is geupload!<br> <a href="FILES/big/'.$_FILES['upload']['name'].'">Zie je file</a><br> '; } else { ?> <form method="post" enctype="multipart/form-data" name="upload"> <table> <tr> <td>File:</td> <td><input type="file" name="upload" id="upload"></td> </tr> <tr> <td>Upload:</td> <td><input type="submit" name="uploaden" value="uploaden"></td> </tr> </table> </form> <? } ?>
Medewerker edit
Even de code-tag correct afgesloten .
|