ziedinjsh Posted May 11, 2010 Report Share Posted May 11, 2010 Tā tad, šāds ir kods: <?php include "../misc/db.php"; if(isset($_POST['add'])){ $author = strip_tags($_POST['author']); $title = strip_tags($_POST['title']); $discription = strip_tags($_POST['discription']); $date = date("j, n, Y"); $cover_folder = "../cover/"; $cover_path = $cover_folder . basename($_FILES['cover']['name']); $cover = basename($_FILES['cover']['name']); $audio_folder = "../mp3/"; $audio_path = $audio_folder . basename($_FILES['audio']['name']); $audio = basename($_FILES['audio']['name']); $relese = mysql_query("INSERT INTO relise (author, title, discription, date, cover, audio) VALUES ('$author', '$title', '$discription', '$date', '$cover', '$audio') "); move_uploaded_file($_FILES['cover']['tmp_name'], $cover_folder); move_uploaded_file($_FILES['audio']['tmp_name'], $audio_folder); echo "Done!"; } ?> <form method='post' action='add.php'> Author:<input type ='text' name='author'> Title:<input type='text' name='title'> Discription:<input type='text' name='discription'> Cover:<input type='file' name='cover'> Audio:<input type='file' name='audio'> <input type='submit' name='add' value='Add'> </form> Nospiežod pogu add notiek sekojošas lietas. Pirmkārt jau izlec notices: Notice: Undefined index: cover in D:\WEB\www\r\admin\add.php on line 12 Notice: Undefined index: cover in D:\WEB\www\r\admin\add.php on line 13 Notice: Undefined index: audio in D:\WEB\www\r\admin\add.php on line 16 Notice: Undefined index: audio in D:\WEB\www\r\admin\add.php on line 17 Notice: Undefined index: cover in D:\WEB\www\r\admin\add.php on line 22 Notice: Undefined index: audio in D:\WEB\www\r\admin\add.php on line 23 bet tas nu tā, galvenais ir tas, ka author, title, description ievadās iekš mysql, bet cover un audio neievadās un faili neaugšupielādējas, kas par vainu? Paldies jau iepriekš! :) Quote Link to comment Share on other sites More sharing options...
briedis Posted May 11, 2010 Report Share Posted May 11, 2010 ko print_r($_POST); izvada? Quote Link to comment Share on other sites More sharing options...
rATRIJS Posted May 11, 2010 Report Share Posted May 11, 2010 http://www.htmldog.com/reference/htmltags/form/ Iipashu uzmaniibu pieveers enctype atribuutam. Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted May 11, 2010 Author Report Share Posted May 11, 2010 it kā visu izvada, vienīgais pie cover un audio ir tikai faila nosaukums, bet it kā jau jābūt ar folderu (cover/bilde.jpg, mp3/kkas.mp3) Quote Link to comment Share on other sites More sharing options...
waplet Posted May 11, 2010 Report Share Posted May 11, 2010 kur nafig ir drosība? Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted May 11, 2010 Author Report Share Posted May 11, 2010 bet kapēc nafig nestrādā?? Quote Link to comment Share on other sites More sharing options...
rATRIJS Posted May 11, 2010 Report Share Posted May 11, 2010 Tu izlasīji ko es rakstīju? (tajā skaitā linku) Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted May 11, 2010 Author Report Share Posted May 11, 2010 ieliku <?php include "../misc/db.php"; if(isset($_POST['add'])){ $author = strip_tags($_POST['author']); $title = strip_tags($_POST['title']); $discription = strip_tags($_POST['discription']); $date = date("j, n, Y"); $cover_folder = "../cover/"; $cover_path = $cover_folder . basename($_FILES['cover']['name']); $cover = basename($_FILES['cover']['name']); $audio_folder = "../audio/"; $audio_path = $audio_folder . basename($_FILES['audio']['name']); $audio = basename($_FILES['audio']['name']); $relese = mysql_query("INSERT INTO relise (author, title, discription, date, cover, audio) VALUES ('$author', '$title', '$discription', '$date', '$cover', '$audio') "); move_uploaded_file($_FILES['cover']['tmp_name'], $cover_folder); move_uploaded_file($_FILES['audio']['tmp_name'], $audio_folder); echo "Done!"; print_r($_POST); } ?> <form action='add.php' method='post' enctype='multipart/form-data'> Author:<input type ='text' name='author'> Title:<input type='text' name='title'> Discription:<input type='text' name='discription'> Cover:<input type='file' name='cover'> Audio:<input type='file' name='audio'> <input type='submit' name='add' value='Add'> </form> pazuda notices, bet nu pārējais bez izmaiņām un tagad vairs ziņa echo "Done!"; neparādās Quote Link to comment Share on other sites More sharing options...
mefisto Posted May 11, 2010 Report Share Posted May 11, 2010 A tu droši zini ka tev ir tiesības rakstīt tai folderī ? Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted May 12, 2010 Author Report Share Posted May 12, 2010 jā, droši zinu Quote Link to comment Share on other sites More sharing options...
rATRIJS Posted May 12, 2010 Report Share Posted May 12, 2010 debugo un skaties kur viss apstaajas... (ja jau apstaajas ta jau Fatal error, bet neredzu kur taads vareetu buut). Ja nav, tad ifs neizpildaas. Quote Link to comment Share on other sites More sharing options...
Maris-S Posted May 12, 2010 Report Share Posted May 12, 2010 Ja Tev if izpildās, tad iespējams nenostrādā vaicājums vai arī move_uploaded_file(), paskaties vai tagad datubāzē parādās ieraksts, kad esi izlabojis formai enctype='multipart/form-data'? Būtībā ja šīs vietas nestrādātu, tad laikam izvadītos kļūdu paziņojumi, iespējams ka tomēr ceļš uz augšupielādes direktorijām nav pareizi norādīts. Quote Link to comment Share on other sites More sharing options...
Maris-S Posted May 12, 2010 Report Share Posted May 12, 2010 Pag, vai tad move_uploaded_file kā destination nav jānorāda pilns faila nosaukums? Tev tur ir direktorija tikai. Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted May 12, 2010 Author Report Share Posted May 12, 2010 (edited) viņš ievad datus, bet pie cover un audio viņš ieliek bildes nosaukumu un failus neaugšupielādē! kapēc pie audi viņš ieliek to pašu ko pie bildes un nav faila precīzs links piem. kā: cover/image.jpg? parāda tikai image.jpg un pie audio tas pats, kapēc viņš audio nenolasa? :? Tagad vispār viņš neko neievada.. neparādās neviens errors, nekas. Tasir sviests.. izmet warningus: Warning: move_uploaded_file() [function.move-uploaded-file]: The second argument to copy() function cannot be a directory in D:\WEB\www\r\admin\add.php on line 19 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'D:\WEB\tmp\php5437.tmp' to 'cover/' in D:\WEB\www\r\admin\add.php on line 19 Tas nozīmē ka vajag pilnu direktoriju, bet man ir tads pats kods citur un viņš visu izdara!! Edited May 12, 2010 by ziedinjsh Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted May 12, 2010 Author Report Share Posted May 12, 2010 <?php error_reporting(E_ALL); include "../misc/db.php"; if(isset($_POST['add'])){ $author = strip_tags($_POST['author']); $title = strip_tags($_POST['title']); $discription = strip_tags($_POST['discription']); $date = date("j, n, Y"); $cover_dir = "../cover/"; $cover_path = $cover_dir . basename($_FILES['cover']['name']); $cover = basename($_FILES['cover']['name']); move_uploaded_file($_FILES['cover']['tmp_name'], $cover_path); $relise = mysql_query("INSERT INTO relise (author, title, discription, date, cover, audio) VALUES ('$author', '$title', '$discription', '$date', '$cover', '$audio') "); echo "Done!"; } ?> <form action='add.php' method='post' enctype='multipart/form-data'> Author:<input type ='text' name='author'> Title:<input type='text' name='title'> Discription:<input type='text' name='discription'> Cover:<input type='file' name='cover'> <input type='submit' name='add' value='Add'> </form> tagad iet.. vismaz cover, bet kad pielieku viasu topašu arī audio, tad audio nepievienojas Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.