Upload system
Ik heb heel google afgezocht en kom geen één script tegen dat werkt. Ik denk dat dit aan mij ligt?
Ik heb dit script gebruikt: http://techstream.org/Web-Development/PHP/Single-File-Upload-With-PHP
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
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
<?php
if(isset($_FILES['image'])){
$errors= array();
$file_name = $_FILES['image']['name'];
$file_size =$_FILES['image']['size'];
$file_tmp =$_FILES['image']['tmp_name'];
$file_type=$_FILES['image']['type'];
$file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));
$extensions = array("jpeg","jpg","png");
if(in_array($file_ext,$extensions )=== false){
$errors[]="extension not allowed, please choose a JPEG or PNG file."
}
if($file_size > 2097152){
$errors[]='File size must be excately 2 MB';
}
if(empty($errors)==true){
move_uploaded_file($file_tmp,"images/".$file_name);
echo "Success";
}else{
print_r($errors);
}
}
?>
<form action="" method="POST" enctype="multipart/form-data">
<input type="file" name="image" />
<input type="submit"/>
</form>
if(isset($_FILES['image'])){
$errors= array();
$file_name = $_FILES['image']['name'];
$file_size =$_FILES['image']['size'];
$file_tmp =$_FILES['image']['tmp_name'];
$file_type=$_FILES['image']['type'];
$file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));
$extensions = array("jpeg","jpg","png");
if(in_array($file_ext,$extensions )=== false){
$errors[]="extension not allowed, please choose a JPEG or PNG file."
}
if($file_size > 2097152){
$errors[]='File size must be excately 2 MB';
}
if(empty($errors)==true){
move_uploaded_file($file_tmp,"images/".$file_name);
echo "Success";
}else{
print_r($errors);
}
}
?>
<form action="" method="POST" enctype="multipart/form-data">
<input type="file" name="image" />
<input type="submit"/>
</form>
Ik krijg deze error:
Code (php)
1
Parse error: syntax error, unexpected '}' in /home/#####/domains/#####.nl/public_html/upload/index.php on line 12
Wat betekent dat?
Mvg,
Lijn 11. Punt-komma mist op het eind.
Code (php)
1
2
3
2
3
Warning: move_uploaded_file(images/STONES.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/####/domains/#####.nl/public_html/upload/index.php on line 17
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpqtUvjM' to 'images/STONES.jpg' in /home/####/domains/######.nl/public_html/upload/index.php on line 17
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpqtUvjM' to 'images/STONES.jpg' in /home/####/domains/######.nl/public_html/upload/index.php on line 17
Gewijzigd op 04/11/2013 20:48:35 door Bart Matsko
Heb je de map wel chmod 777 gegeven?
Probeer liever eerst 755...
Ik ben er zelf al achter, ik moet niet de files 777 geven maar de map...