Hej udviklere, er igang med at "sikre" mit upload script så det kun er billedefiler under 2mb der kan blive uploaded
men har et problem med unexpected $end i linje 54
håber i kan finde fejlen.
- <?php
-
- include('../connect.php');
-
- $username = $_SESSION['username'];
-
- if($_POST['submit'])
- {
- $name = $_FILES['myfile']['name'];
- $tmp_name = $_FILES ['myfile']['tmp_name'];
-
- $errors = array();
- $allowed_ext = array('jpg', 'jpeg', 'png', 'gif');
-
- $file_name = $_FILES['myfile']['name'];
- $file_ext = strtolower(end(explode('.', $file_name)));
- $file_size = $_FILES['myfile']['size'];
- $file_tmp = $_FILES['myfile']['tmp_name'];
-
- if (in_array($file_ext, $allowed_ext) === false) {
- $errors[] = 'Filen er ikke tilladt!';
- }
-
- if ($file_size > 2097152) {
- $errors[] = 'Filen er for stor!';
- }
- if (empty($errors)){
- //upload
- $location = "../galleri/$name&$username";
- move_uploaded_file($tmp_name,$location);
-
- $query = mysql_query("INSERT INTO galleri VALUES ('','$username','$location')");
- header( 'Location: http://miino.net/galleri.php?bruger='.$username);
-
- }
-
- else{
- foreach ($errors as $error) {
- echo $error, '<br />';
- }
- }
-
-
-
-
- echo "<br><br>Upload et billede til dit galleri:
- <br /><br />
- <form action='includes/galleri.php' method='POST' enctype='multipart/form-data'>
- <input type='file' name='myfile'> <input class='button' type='submit' name='submit' value='Upload'>
-
- </form>
- ";
- ?>