Bijlage in database opslaan en aanroepen
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
error_reporting(E_ALL);
$map = "./upload/"; // Map waar alles geupload wordt
function upload_file($fTmp, $fNew) {
if(file_exists($fNew)) {
rename($fNew, $fNew . 'bu');
}
copy($fTmp, $fNew);
return true;
}
if(IsSet($_POST['submit'])) {
for($i = 0; $i < count($_FILES['bestand']['name']); $i++) {
if(IsSet($_FILES['bestand']['name'][$i]) && is_uploaded_file($_FILES['bestand']['tmp_name'][$i])) {
if(!upload_file($_FILES['bestand']['tmp_name'][$i], $map.$_FILES['bestand']['name'][$i])) {
$error = true;
}
}
}
if(IsSet($error)) {
echo "Mislukt!";
} else {
echo '<a href="domein.nl'.$map.$_FILES['bestand']['name'][$i].'">Het uploaden is gelukt</a>';
}
} else {
if(IsSet($_POST['aantal'])) {
$aantal = $_POST['aantal'];
} else {
$aantal = 2;
}
?>
error_reporting(E_ALL);
$map = "./upload/"; // Map waar alles geupload wordt
function upload_file($fTmp, $fNew) {
if(file_exists($fNew)) {
rename($fNew, $fNew . 'bu');
}
copy($fTmp, $fNew);
return true;
}
if(IsSet($_POST['submit'])) {
for($i = 0; $i < count($_FILES['bestand']['name']); $i++) {
if(IsSet($_FILES['bestand']['name'][$i]) && is_uploaded_file($_FILES['bestand']['tmp_name'][$i])) {
if(!upload_file($_FILES['bestand']['tmp_name'][$i], $map.$_FILES['bestand']['name'][$i])) {
$error = true;
}
}
}
if(IsSet($error)) {
echo "Mislukt!";
} else {
echo '<a href="domein.nl'.$map.$_FILES['bestand']['name'][$i].'">Het uploaden is gelukt</a>';
}
} else {
if(IsSet($_POST['aantal'])) {
$aantal = $_POST['aantal'];
} else {
$aantal = 2;
}
?>
<form action="#" method="post">
<input type="text" name="aantal" value="" size="1"> <input type="submit" name="aantal_submit" value="Aantal bestanden">
</form>
<br><br>
<form action="#" method="post" enctype="multipart/form-data">
Bestand : <input type="file" name="bestand[]"> <input type="checkbox" name="formWheelchair[]" value="" /><br>
<input type="submit" name="submit" value="Uploaden">
</form>
Wat is er mis met http://www.phphulp.nl/php/forum/topic/bijlage-link-laten-zien-in-de-zelfde-pagina/85902/last/
Ja, klopt het was een vergissing