Jump to content
php.lv forumi

img ielade


didy

Recommended Posts

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 by didy
Link to comment
Share on other sites

<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"

Link to comment
Share on other sites

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 by Mikijs
Link to comment
Share on other sites

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");

Link to comment
Share on other sites

<?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!

Link to comment
Share on other sites

<?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 by didy
Link to comment
Share on other sites

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

Link to comment
Share on other sites

×
×
  • Create New...