ziedinjsh Posted October 16, 2009 Report Share Posted October 16, 2009 Sveiki. Šādi izskatās kods: <?php include "misc/config.php"; if (isset($_POST['get_photo'])) { // faila detaljas $p_name = $_FILES["photo"]["name"]; $p_type = $_FILES["photo"]["type"]; $p_size = $_FILES["photo"]["size"]; $p_temp = $_FILES["photo"]["tmp_name"]; $p_error = $_FILES["photo"]["error"]; $p_date = date("y-m-d"); if($p_error > 0) die ("photo culd not uploaded! Code: $p_error"); else { //Faila nosaciijumi if($p_type == "application/octet-stream" || $p_size >3145728) { die("this format is not allowed or file is to big"); } else { $query = mysql_query("INSERT INTO photos (p_name, p_type, p_size, p_date) VALUES ('','$p_name','$p_type','$p_size','$p_date') "); move_uploaded_file($p_temp,"uploads/".$p_name); echo "photo uploaded!"; } } } echo "<form method='post' action='".$_SERVER['PHP_SELFE']."' enctype='multipart/form-data'>"; echo "<input type='file' name='photo'>"; echo "<input type='submit' value='Upload' name='get_photo'>"; echo "</form>"; ?> failu viņš augšupielādē, bet informāciju datubāzē neieliek.. kas nav pareizi? kur man jālike md5(); funkcija lai augšupielādējot faili viņš būtu nokodēts ar md5(); un paliktu faila formāts? meiģināju šādi: $p_name = md5($_FILES["photo"]["name"]); failu viņš nokodēja ar md5 bet fomāts galā nebija varbūt ir kāds gatavs kods kur datus ieliek mysql un var augšupielādēt tikai bilžu failus ar md5(); funkciju? Quote Link to comment Share on other sites More sharing options...
Aleksejs Posted October 16, 2009 Report Share Posted October 16, 2009 Priekš kam tev to md5 vispār vajag šajā vietā? Izlasi šito: http://php.lv/f/topic/14308-dokumentipamacibas-par-php-un-web-aplikaciju-drosibu/page__view__findpost__p__111056 Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted October 16, 2009 Author Report Share Posted October 16, 2009 nevienu scriptu neizdodas palaist.. tiešman vav kaut kāds vienkārs upload scripts kurš atļauj tikai bilžu fomātus augšupielādēt un ieliek datus iekš db lai pēc tam var izvilkt tās bildes kkur? Quote Link to comment Share on other sites More sharing options...
esd29a Posted October 16, 2009 Report Share Posted October 16, 2009 $query = mysql_query("INSERT INTO photos (p_name, p_type, p_size, p_date) VALUES ('','$p_name','$p_type','$p_size','$p_date') "); "photos" noraada 4 laukus bet VALUES ir 5. Taa varbuut probleema? Tu saki "informāciju datubāzē neieliek" - vai kaadu sql kljuudu nemet esi skatiijies ? Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted October 16, 2009 Author Report Share Posted October 16, 2009 (edited) it kā jau nemet.. jo no no text formām infomāciju ievada Tagad pievienojās Edited October 16, 2009 by ziedinjsh Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted October 16, 2009 Author Report Share Posted October 16, 2009 atkal jautājums.. kā tagad es augšupielādejot bildi man vēl uztaisās thumbnail citā folderā? Quote Link to comment Share on other sites More sharing options...
rATRIJS Posted October 16, 2009 Report Share Posted October 16, 2009 Hmmm - sāc ar normālu domas izklāstu. Savādāk no jautājuma saprast neko īsti nevar. Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted October 16, 2009 Author Report Share Posted October 16, 2009 Šāds ir kods: <?php error_reporting(E_ALL); include "misc/config.php"; if (isset($_POST['get_photo'])) { // faila detaljas $p_name = $_FILES["photo"]["name"]; $p_type = $_FILES["photo"]["type"]; $p_size = $_FILES["photo"]["size"]; $p_temp = $_FILES["photo"]["tmp_name"]; $p_error = $_FILES["photo"]["error"]; $p_date = date("Y-m-d"); $p_time = time("H:i:s"); if($p_error > 0) die ("photo culd not uploaded! Code: $p_error"); else { //Faila nosaciijumi if($p_type == "application/octet-stream" || $p_size >3145728) { die("this format is not allowed or file is to big"); } else { $query = mysql_query("INSERT INTO photos (p_name, p_type, p_size, p_date, p_time) VALUES ('$p_name','$p_type','$p_size','$p_date', 'p_time') "); move_uploaded_file($p_temp,"uploads/".$p_name); echo "photo uploaded!"; } } } echo "<form method='post' action='".$_SERVER['PHP_SELF']."' enctype='multipart/form-data'>"; echo "<input type='file' name='photo'>"; echo "<input type='submit' value='Upload' name='get_photo'>"; echo "</form>"; ?> viņš augšupielādē bildi iek uploads foldera.. un ieliek datus iekš mysql. Tātad.. Kā varētu uztaisīt tā kad augšupielādējas bilde un arī taj pašai bildei izveidojas thumbnail iekš uploads/small 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.