пак помощ с ъплоуд на картинки

Пробвай така
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Upload на файлове</title>
<meta http-equiv="content-type" content="text/html; charset=windows-1251">
</head>
<body>
<center>
<?php
if(isset($_POST['submit'])){
mysql_connect("localhost","root",******);
mysql_select_db("obqvi");
mysql_query("SET CHARACTER SET cp1251");

$image_tempname = $_FILES['image_filename']['name'];

$ImageDir ="files/";

$ImageName = $ImageDir . $image_tempname;

$today = date("Y-m-d H:i:s");

$site_url="http://85.187.40.21/m555/";

if (move_uploaded_file($_FILES['image_filename']['tmp_name'],
$ImageName)) {

list($width, $height, $type, $attr) = getimagesize($ImageName);

if ($type > 3) {
echo "Съжеляваме но файла трябва да бъде от тип JPEG,Gif " .
"или PNG.<br>";
echo "Моля опитайте отново.";
} else {

$newfilename = $site_url . $ImageDir . $today . ".jpg";

if ($type == 2) {
rename($ImageName, $newfilename);
} else {
if ($type == 1) {
$image_old = imagecreatefromgif($ImageName);
} elseif ($type == 3) {
$image_old = imagecreatefrompng($ImageName);
}

$image_jpg = imagecreatetruecolor($width, $height);
imagecopyresampled($image_jpg, $image_old, 0, 0, 0, 0,
$width, $height, $width, $height);
imagejpeg($image_jpg, $newfilename);
imagedestroy($image_old);
imagedestroy($image_jpg);
}

$q = "INSERT INTO files
(id_ob, pic)
VALUES
(NULL, '$newfilename')";
$insertresults = mysql_query($q)
or die(mysql_error());

}
}

if($q){
echo "Файлът беше успешно качен";
}else{
echo "Грешка</center>";
exit;
}
}
?>



Файл
<form>
<br>
<input name="file" type="file">
<br>
<input name="submit" type="submit">
</form>


</center>
</body>
</html>
 
Ако с това не се оправиш се откажи:

Това е ъплоуд на 5 картинки от компера (name-овете във формата са:
file, file1, file2, file3, file4)




$files = array( 'file', 'file1', 'file2', 'file3', 'file4');

$count = count( $files );

$out = array();



for( $i = 0; $i < $count; $i++ ) {

$out[$i] = 'ПЪТЯ ДО СНИМКАТА КОЯТО ЩЕ Е ПО DEFAUT АКО ПОТРЕБИТЕЛЯ НЕ КАЧИ НИЩО';



if( is_uploaded_file( $_FILES[ $files[$i] ]['tmp_name'] ) ) {

$tmp_file = $_FILES[ $files[$i] ]['tmp_name'];

$name = $_FILES[ $files[$i] ]['name'];

$nom_file = mktime() . $name;


$out[$i] = "http://URL-ТО ДЕТ ША СЕ КАЧВА СНИМКАТА!!!!!!!!/files/{$nom_file}";

move_uploaded_file( $tmp_file, "files/{$nom_file}" );
}

$extensions = array("jpg","png","gif","");//позволени типове
$extension_file = end(explode(".",$name));
$extension_file = strtolower($extension_file);
if(!in_array($extension_file,$extensions))
{
$error_picturce_type = '';
$error_picturce_type = "<p>Непозволен тип снимка(.jpg, .png, .gif).</p>";
include "ДЕТ СА ПИШАТ СНИМКИТЕ.php";
exit;
}
}
mysql_query(" INSERT INTO pics (picturce, picturce1, picturce2, picturce3, picturce4) VALUE ('{$out[0]}', '{$out[1]}', '{$out[2]}', '{$out[3]}', '{$out[4]}') ", $mysql );
 
някой ще ми помогне ли най-после като направи тази проста форма да работи :idea:
 
Ми като се научиш на най най най най най най елементарни познаия по php. По добре захвърли програмирането. не е за теб!
 
hackera това което ти написах аз при мен работи незнам какво правиш да не да не въвеждаш паролата за бд-то грешно
 

Back
Горе