---
title: "move_uploaded_file()"
type: "forum-thread"
url: "https://www.webforum.nu/amne/php/120313-move-uploaded-file"
topic: "PHP"
topic_url: "https://www.webforum.nu/amne/php"
author: "Humble"
published: "2005-01-17T15:18:04.000Z"
updated: "2005-01-19T14:03:05.000Z"
replies: 4
views: 403
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/php/120313-move-uploaded-file"
---

# move_uploaded_file()

## #1 — Humble, 2005-01-17T15:18Z

Försöker få till ett fotoalbum, där denna funktion ingår. Eftersom det är på b-one.net så är som jag fattat register_globals=off samt att dom kör i safe mode on. Får alltså felmeddelande att funtionen move-uploaded_file inte funkar. Kan dock se att tmp_filen finns. Kan man kringgå detta på något sätt ex. med copy(). Har en aning om jag sett detta någonstans.

Permalänk: https://www.webforum.nu/p/120313

## #2 — Matte, 2005-01-17T18:56Z

copy fungerar inte under safe_mode, men däremot ska move_uploaded_file göra det.

Hur ser din kod ut ?
Vad får du för felmeddelande ?

Permalänk: https://www.webforum.nu/p/1531577

## #3 — Humble, 2005-01-17T22:20Z

felmeddelande

move_uploaded_file(): URL file-access is disabled in the server configuration 
och failed to open stream: no suitable wrapper could be found samt move_uploaded_file(): Unable to move '/tmp/phpz4csVu' to 'http://www.mindomän.se/album/images/sunset.jpg' .

Här är koden:

```php
<?php
include "album_config.inc.php";
// Use Heredoc syntax to format the XHTML form
$addPhotoForm = <<< addPhotoForm
<p>Add a photo to the album</p>
 <!-- Här har jag ändrat action sidan eftersom fel filnamn kommentaren inom HTML eftersom Heredocsyntax-->
<form action="add_photo.php"
enctype="multipart/form-data" method="post">
<p> 
          Photo:<br />
		  <input name="photo" type="file" />
		  </p>
     <p>
	 Descriptive Title:<br />
	 <input type="text" name="title"
	 size="40" maxlength="80" value="" />
	 </p>

     <p>
	 Description:<br />
	 <textarea name="description"
	 rows="3" cols="40"></textarea>
	 </p>

     <p>
	 <input type="submit" value="Add photo!" />
	 </p>
	 </form>
addPhotoForm;
// If the user has submitted a file for uploading.
if (is_uploaded_file($_FILES['photo']['tmp_name'])){
# Add the photo to the MySQL database
add_photo($_FILES['photo']['name'], $_POST['title'],$_POST['description']) or die("couldnt add photo");
# Move the photo from the temp directory to
# the images directory.
move_uploaded_file($_FILES['photo']['tmp_name'], ABSOLUTE_PATH.$_FILES['photo']['name']);
    echo "<p>The photo was successfully uploaded .</p>";
	echo "$tmp_name";
	} 
// display the form on every page instance
echo $addPhotoForm;
?>
```

Permalänk: https://www.webforum.nu/p/1531710

## #4 — Matte, 2005-01-18T18:07Z

move_uploaded_file arbetar mot filsystemet. Du försöker flytta filen via http.

Ändra till en sökväg i filsystemet. 
Alltså där du har konstanten ABSOLUTE_PATH ska du istället ha en sökväg till katalogen via filsystemet, antingen relativt eller absolut från diskroten.

Permalänk: https://www.webforum.nu/p/1532120

## #5 — Humble, 2005-01-19T14:03Z

Tack förhjälpen!

Var problem med sökvägen som jag löste tack vara Ditt svar.

Permalänk: https://www.webforum.nu/p/1532623

---

Tråden på webben: https://www.webforum.nu/amne/php/120313-move-uploaded-file
