Hey jeg prøver at få det her upload script til at virke, hvori
den også skriver data til mysql databsen...
SElve formen ser således ud:
<form enctype="multipart/form-data" action="uploadsongdata.php"
method="POST">
Username: <input type="text" name="username" value="<? echo
"$session->username";?>" readonly="readonly" /><br>
Userid: <input type="text" name="userid" value="<? echo
"$session->id";?> " readonly="readonly" /><br>
Title: <input type="text" name="title"><br>
Description: <input type="text" name="description"><br>
Song: <input type="file" name="song"><br>
<input type="submit" value="Add"> </form>
Ingen fejl her.
I uploadsongdata.php er den kode som tager sig af filen således
ud:
// Sets upload directory
$path = "songs";
// File from the form
$file = $_FILES['song']['title'];
//This gets all the other information from the form
$artistid=$_POST['userid'];
$title=$_POST['title'];
$description=$_POST['description'];
$song=($_FILES['song']['title']);
// Writes to the Database
mysql_query("INSERT INTO `songs` VALUES ('$artistid', '$title',
'$description', '$song')") ;
//Writes the song to the server
if(move_uploaded_file($file, "$path/$file")) {
//Tells if everything is ok
echo "The file ".$file. " has been uploaded, and your information
has been added to the directory"; }
else {
//If not, gives and error
echo "Sorry, there was a problem uploading your song."; }
Den skriver blot fejl meddelelsen: "Sorry, There was a problem
uploading your song."
Nogen som kan spotte fejlen og hvordan man retter den?
På forhånd tak..
// Ralle
--
Vil du lære at kode HTML, XHTML, CSS, SSI, ASP eller ASP.NET?
- Pædagogiske tutorials på dansk
- Kom godt i gang med koderne
KLIK HER! =>
http://www.html.dk/tutorials