didy Posted February 20, 2008 Report Posted February 20, 2008 (edited) Ir izveidots upload kodins. Augsupladejot bildi vina saglabajas noteiktaja mape! Jautajum: Ka lai izveidoju lai augsupledaatais fails saglabaajas un nopostojas weba! edit: PS. atradu info! Paldies, tiksu gala! Edited February 20, 2008 by didy
andrisp Posted February 20, 2008 Report Posted February 20, 2008 Nu bet tu taču pats saki, ka jau ir izveidots kodiņš. Kas tev tieši nedarbojas ?
didy Posted February 21, 2008 Author Report Posted February 21, 2008 <form enctype="multipart/form-data" action=" upload.php" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="250000" /> Send this file: <input name="Picture" type="file" /> <input type="submit" value="Send File" /> </form> if (isset($Picture)) { If($Picture != "none") { $PSize = filesize($Picture); $mysqlPicture = addslashes(fread(fopen($Picture, "r"), $PSize)); } require ($_SERVER["DOCUMENT_ROOT"]."/fold/configs.php"); $connection = @mysql_connect($db_host, $db_user, $db_password) or die ("error connecting"); mysql_select_db($db_name, $connection); mysql_query("INSERT INTO img_upload (Image) VALUES ('$mysqlPicture')") or die("Can't Perform Query"); } else { echo"You did not upload any picture"; } ?> Kadel nesanak augsupladet datubaze ? Ko esmu nepareizi izdarijis? izvada man else - "You did not upload any picture"
andrisp Posted February 21, 2008 Report Posted February 21, 2008 Vispār jau dati par augšupielādēto failu būs $_FILES['Picture'] mainīgajā. Uztaisi tam print_r() un papēti, kas tur ir iekšā un pārraksti savu kodu.
Mikijs Posted February 21, 2008 Report Posted February 21, 2008 (edited) action formai nepareizs " upload.php" jabut "upload.php" bet tam nevaidzetu but svarigam Edited February 21, 2008 by Mikijs
Mikijs Posted February 21, 2008 Report Posted February 21, 2008 (edited) njem rekur normals uploads upload.php <?php $bilde=$_FILES['bilde']; $file_ext=strtolower(substr($bilde[name], strrpos($bilde[name], "."))); //Parbaudam kopbildi if($file_ext==".jpg" OR $file_ext==".jpeg" OR $file_ext==".png") { $fails=time().$file_ext; // FAILA NOSAUKUMS vari lietot arii "images/manas_bildes".ID.$file_ext UTt.. $res = move_uploaded_file($bilde[tmp_name], $fails); @chmod($fails, 0755); }else{ die('Pārliecinies vai kopbildes bilde ir JPG, vai PNG fails!'); } index.php <form action="upload.php" enctype="multipart/form-data" method="post"> <input type="file" size="41" name="bilde"> <input type="submit"> </form> Edited February 21, 2008 by Mikijs
Mikijs Posted February 21, 2008 Report Posted February 21, 2008 a un tava kljuda!!! tav kas tev bija atradu ;) tev iepriekseja posta ir tada rindinja require ($_SERVER["DOCUMENT_ROOT"]."/folder/configs.php"); gandriz tada pati ka seit tikai atskiriba ta ka te tev ir require ($_SERVER["DOCUMENT_ROOT"]."/folder/configs.php");
didy Posted February 21, 2008 Author Report Posted February 21, 2008 <?php if (isset($_FILES['Picture'])) { If($Picture != "none") { $PSize = filesize($Picture); $mysqlPicture = addslashes(fread(fopen($Picture, "r"), $PSize)); } require ($_SERVER["DOCUMENT_ROOT"]."/folder/configs.php"); $connection = @mysql_connect($db_host, $db_user, $db_password) or die ("error connecting"); mysql_select_db($db_name, $connection); mysql_query("INSERT INTO img_upload (Image) VALUES ('$mysqlPicture')") or die("Can't Perform Query"); } else { echo"You did not upload any picture"; } ?> Joprojam neka! Izmet joprojam else - "You did not upload any picture" Kluda "equire ($_SERVER["DOCUMENT_ROOT"]."/folder/configs.php");" nebus vainiga, ka ari "upload.php" Man nikis pirms postesanas nomainit foldera un lapas nosaukumu! Nejauta kadeel! Man vaig uploudu ar DB! Meklesu vel!
andrisp Posted February 21, 2008 Report Posted February 21, 2008 Tu taču tāpat turpini izmanto $Picture mainīgo tāpat kā sākumā..
didy Posted February 21, 2008 Author Report Posted February 21, 2008 If($Picture != "none") { $PSize = filesize($Picture); $mysqlPicture = addslashes(fread(fopen($Picture, "r"), $PSize)); nomainot $Picture mainigo uz $_FILES['Picture'] - reakcija nekada!
andrisp Posted February 21, 2008 Report Posted February 21, 2008 A tu paskatījies no kā sastāv $_FILES['Picture'] ? Tas ir masīvs.
didy Posted February 22, 2008 Author Report Posted February 22, 2008 (edited) <?php if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/jpg") || ($_FILES["file"]["type"] == "image/png") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 20000)) { if ($_FILES["file"]["error"] > 0) { echo "Error: " . $_FILES["file"]["error"] . "<br />"; $mysqlp = addslashes(fread(fopen($_FILES["file"]["type"], "r"), $_FILES["file"]["size"])); } else { require ($_SERVER["DOCUMENT_ROOT"]."/folder/configs.php"); $connection = @mysql_connect($db_host, $db_user, $db_password) or die ("error connecting"); mysql_select_db($db_name, $connection); if (isset($_POST['mysqlp'])){ mysql_query("INSERT INTO img_upload (Image) VALUES ('$mysqlp')") or die("Can't Perform Query"); } echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Stored in: " . $_FILES["file"]["tmp_name"] . "<br /><br />"; } } else { echo "Invalid file"; } ?> Samonteju sadu skriptinu. Itka nekadas kludas neuzrada, bet DB nesaglabajas! KO izdariju nepareizi? Edited February 22, 2008 by didy
didy Posted February 25, 2008 Author Report Posted February 25, 2008 piemetu: mysql_query($query, $connection) or die (mysql_error()); ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1' at line 1
andrisp Posted February 25, 2008 Report Posted February 25, 2008 Izdrukā to kveriju un apskaties kāds viņš izskatās.
Mikijs Posted February 25, 2008 Report Posted February 25, 2008 vecit :) uztaisi tak savu kodu izskatas visi ieprieksejie ir kopeti.. =/ no snippetiem..
Recommended Posts