Jump to content
php.lv forumi

Recommended Posts

Posted

> Nē, es domāju tā, ka tu izmanto tikai lai iegūtu vērtību, nevis tur ierakstītu. Tas pats attiecas uz $_POST masīvu

  • Replies 39
  • Created
  • Last Reply

Top Posters In This Topic

Posted

Kurš mūsdienās vēl vispār izmanto mysql_real_escape_string ???

 

Visi iesācēji, kās vēl nav uzzinājuši, ka ir citi veidi, kā ORM, PDO, etc..

Posted

Skripts, kas pārsūta failus uz web servera.

$query3 = "SELECT id FROM news ORDER BY id DESC LIMIT 1";
$data3 = mysql_query ($query3) or die(mysql_error());
$row3 = mysql_fetch_array( $data3 );
$img_type = explode(".", $_FILES['uploaded']['name']);
$image_ext = ($row3['id'] + 1).".".$img_type['1'];



$target = "upload/" . $image_ext;
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;
$file = $_FILES['uploaded'];
$allowedExtensions = array("jpg", "gif", "png");
function isAllowedExtension($fileName) {
 global $allowedExtensions;

 return in_array(end(explode(".", $fileName)), $allowedExtensions);
}

.....

else
{ if($file['error'] == UPLOAD_ERR_OK) {

if(isAllowedExtension($file['name'])){

if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "The file ". basename( $_FILES['uploaded']['name']). " has been uploaded";
}
else
{
echo "Sorry, there was a problem uploading your file.";
}
}  else {
echo "Wrong file type.(.jpg,.png,.gif)";
}
}
else {
echo "Cant upload error $ok = 0";
}
}

iznākumā vēlos lai faila nosaukums atbilstu $image_ext variablim. Liekot bildes iekšā beigās rezultātam vajadzētu būt 1.jpg 2.jpg 3.png utt. Bet nevaru variabli savienot ar move_uploaded_file. Labākajā variantā man sanāca 1.jpgkautkas.jpg

 

Izskatīju vairākus sourcus iespējams, kaut ko palaižu garām visu laiku.

Guest
This topic is now closed to further replies.

×
×
  • Create New...