Jump to content
php.lv forumi

input type file 2x


ziedinjsh

Recommended Posts

Sveiki!

Ir tāda lieta, ka iekš datubāzes viss saglabājas, bet song un cover netiek augšupielādēti!


<?php
include("../misc/dbase.php");
if(isset($_POST['addsong'])){
$mp3 = "../mp3/";
$jpg = "../cover/";

$mp3_error = mysql_real_escape_string($_FILES['song']['error']);
$mp3_name = mysql_real_escape_string($_FILES['song']['name']);
$mp3_tmp = mysql_real_escape_string($_FILES['song']['tmp_name']);

$jpg_error = mysql_real_escape_string($_FILES['cover']['error']);
$jpg_name = mysql_real_escape_string($_FILES['cover']['name']);
$jpg_tmp = mysql_real_escape_string($_FILES['cover']['tmp_name']);

$artist = mysql_real_escape_string($_POST['artist']);
$title = mysql_real_escape_string($_POST['title']);
$duration = mysql_real_escape_string($_POST['duration']);

$song = $mp3.basename($mp3_name);
$cover = $jpg.basename($jpg_name);

if($mp3_error==0 || $jpg_error==0){
move_uploaded_file($mp3_name, $song);
move_uploaded_file($jpg_name, $cover);
mysql_query("insert into songs (song, cover, artist, title, duration) values ('$mp3_name', '$jpg_name', '$artist', '$title', '$duration')") or die(mysql_error());
echo "jeej";
}else{
echo "fuu";
}
}


echo "
<form method='post' action='".$_SERVER['PHP_SELF']."' enctype='multipart/form-data'>

<p>Izpildītājs</p>
<p><input type='text' name='artist'></p>

<p>Nosaukums</p>
<p><input type='text' name='title'></p>

<p>Garums</p>
<p><input type='text' name='duration'></p>

<p>Bilde</p>
<p><input type='file' name='cover'></p>

<p>Dziesma</p>
<p><input type='file' name='song'></p>

<p><input type='submit' name='addsong' value='jou'></p>
</form>
";
?>

 

kapēc tā?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...