Jump to content
php.lv forumi

banera augšuplāde DB


gkazhus

Recommended Posts

Man ir šāds kods!

Doma ir tāda ka būtu iespēja uploudot kaut kādu baneri un pielikt banerim linku. Kad uzspiež uz banera jaunā logā atveras saite kas norādīt pie banera uploudošanas. Baneris tiek uploudots gan uz servera gan noglabāts MYSQL DB.

Bet kaut kas nav lāgā ar šo kodu! Varat kāds zinošs palīdzēt?

 

 

 

Kods:

 

<?php

 

 

if ((($_FILES["file"]["type"] == "image/gif")

|| ($_FILES["file"]["type"] == "image/jpeg")

|| ($_FILES["file"]["type"] == "image/pjpeg"))

&& ($_FILES["file"]["size"] < 20000))

{

if ($_FILES["file"]["error"] > 0)

{

echo "Return Code: " . $_FILES["file"]["error"] . "<br />";

}

else

{

echo "Upload: " . $_FILES["file"]["name"] . "<br />";

echo "Type: " . $_FILES["file"]["type"] . "<br />";

echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";

echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";

 

if (file_exists("../banners/" . $_FILES["file"]["name"]))

{

echo $_FILES["file"]["name"] . " already exists. ";

}

else

{

move_uploaded_file($_FILES["file"]["tmp_name"],

"../banners/" . $_FILES["file"]["name"]);

echo "Stored in: " . "../banners/" . $_FILES["file"]["name"];

}

}

}

else

{

echo "Invalid file";

}

 

$DatabaseHost = "";

$DatabaseUsername = "";

$DatabasePassword = "";

$DatabaseName = "";

 

$connection = mysql_connect($DatabaseHost, $DatabaseUsername, $DatabasePassword)

or die("Cannot connect to MySQL!");

mysql_select_db($DatabaseName, $connection) or die("Cannot find database!");

 

$sql = " INSERT INTO right_side_banners (ID, active, banner, link_URL)

VALUES (0, 1, \"file", \"link_URL\");";

$rs = mysql_query($sql);

 

print mysql_error();

 

 

 

}

 

?>

Edited by gkazhus
Link to comment
Share on other sites

1) mjā, varbūt vēl ftp pieejas paroles publicē?

2) Tut taču saproti, kas citi nevar šo kodu tā vienkārši palaist uz sava servera, tāpēc vienmēr vajag pateikt, nevis ka kaut kas nav kārtībā, bet kas nav kārtība: kļūdu paziņojumi, kas strādā kā vajag un kas kā nevajag, utt.

Edited by codez
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...