Hej,
Jeg kan ikke få min upload fil til at virke jeg får følgende fejl:
Notice: Undefined index: file in C:\wamp\www\dvd_collectio_original\dvd_upload.php on line 19
som er som følger: $image=$_FILES['file']['name'];
Er der nogen der kan hjælpe mig på vej, jeg er i opbygningsfasen, så jeg arbejder på localhost hvis det kunne have betydning.
- <?php require_once("includes/connection.php"); ?>
- <?php include("includes/header.php"); ?>
-
- <?php
- define ("MAX_SIZE","10000");
-
- function getExtension($str) {
- $i = strrpos($str,".");
- if (!$i) { return ""; }
- $l = strlen($str) - $i;
- $ext = substr($str,$i+1,$l);
- return $ext;
- }
-
- $errors=0;
-
- if(isset($_POST['Submit'])) {
-
- $image=$_FILES['file']['name'];
-
- if ($image) {
- $filename = stripslashes($_FILES['file']['name']);
- $extension = getExtension($filename);
- $extension = strtolower($extension);
- if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) {
- echo '<h1>Unknown extension!</h1>';
- $errors=1;
- }else{
- $size=filesize($_FILES['file']['tmp_name']);
- if ($size > 1000 * 1024){
- echo '<h1>You have exceeded the size limit!</h1>';
- $errors=1;
- }
- $image_name=time().'.'.$extension;
- $newname="dvd_images/dvd_". $_GET["id"] .".jpg";
- $copied = copy($_FILES['file']['tmp_name'], $newname);
- if (!$copied) {
- echo '<h1>Copy unsuccessfull!</h1>';
- $errors=1;
- }else{
- header("Location: dvd_info.php?id=". $_GET["id"]);
- exit;
- }
- }
- }
- }
-
- if(isset($_POST['Submit']) && !$errors) {
- echo "<h1>File Uploaded Successfully!</h1>";
- }
- ?>
-
- <form method="post" enctype="multipart/form-data" action="">
- <table align="center" border="2">
- <tr>
- <td><img src="./dvd_images/dvd_<?php echo $_GET["id"] ?>.jpg" width="200" height="300" /></td>
- </tr>
- <tr>
- <td><input type="file" name="image"> <input name="Submit" type="submit" value="Upload image"></td>
- </tr>
- <tr>
- <td><a href="./dvd_info.php?id=<?php echo $_GET["id"]; ?>">Fortsæt uden upload</a></td>
- </tr>
- </table>
- </form>
-
- <?php require("includes/footer.php"); ?>
Indlæg senest redigeret d. 07.08.2011 23:38 af Bruger #16728