İyinet'e Hoşgeldiniz!

Türkiye'nin En Eski Webmaster Forum'una Hemen Kayıt Olun!

Kayıt Ol!

çoklu db ye kayıt

reflex073

0
İyinet Üyesi
Katılım
20 Aralık 2011
Mesajlar
40
Reaction score
0
Merhaba bir fotoğraf ekleme alanım var. Fotoğrafı ajax ile hosta hemen yüklüyor fakat fotoğraf isimlerini db ye nasıl kayıt edeceğim. DB yapım bu şekilde;

id fotoğraf adı
22 merhaba.jpg
22 nasilsin.jpg

yani tek bir inster değilde seçilen her resim için mysql yeni inster yapmalı ve eğer resim seçili değil ise insert yapmamalı form yapısı;
<input type="file" name="1" />
<input type="file" name="2"/>
.
.
.
.
<input type="file" name="12"/>
 

reflex073

0
İyinet Üyesi
Katılım
20 Aralık 2011
Mesajlar
40
Reaction score
0
Kod:
 <input type="file" class="droparea spot" name="xfile" data-post="includes/content/upload.php" data-width="107" data-height="107" data-crop="true"/>
                         <input type="file" class="droparea spot" name="xfile" data-post="includes/content/upload.php" data-width="107" data-height="107" data-crop="true"/>
                         <input type="file" class="droparea spot" name="xfile" data-post="includes/content/upload.php" data-width="107" data-height="107" data-crop="true"/>
                         <input type="file" class="droparea spot" name="xfile" data-post="includes/content/upload.php" data-width="107" data-height="107" data-crop="true"/>
                         <input type="file" class="droparea spot" name="xfile" data-post="includes/content/upload.php" data-width="107" data-height="107" data-crop="true"/>
                         <input type="file" class="droparea spot" name="xfile" data-post="includes/content/upload.php" data-width="107" data-height="107" data-crop="true"/>
                         <input type="file" class="droparea spot" name="xfile" data-post="includes/content/upload.php" data-width="107" data-height="107" data-crop="true"/>
                         <input type="file" class="droparea spot" name="xfile" data-post="includes/content/upload.php" data-width="107" data-height="107" data-crop="true"/>
                         <input type="file" class="droparea spot" name="xfile" data-post="includes/content/upload.php" data-width="107" data-height="107" data-crop="true"/>
                         <input type="file" class="droparea spot" name="xfile" data-post="includes/content/upload.php" data-width="107" data-height="107" data-crop="true"/>
                         <input type="file" class="droparea spot" name="xfile" data-post="includes/content/upload.php" data-width="107" data-height="107" data-crop="true"/>





myql intosu da tablomuz resimler - id ve resim bu kadar
 

metadige

0
İyinet Üyesi
Katılım
23 Aralık 2005
Mesajlar
354
Reaction score
4
Arkadaşım sadece form kodların değil, o formu işleyen ajaxın post edildiği php dosyasının içeriğini eklemen lazım.
 

reflex073

0
İyinet Üyesi
Katılım
20 Aralık 2011
Mesajlar
40
Reaction score
0
form olan sayfa
Kod:
<?php session_start(); ob_start(); if($dzyblrle == 0) { die(Header("Location:login.php")); } ?>
<?php include 'includes/core/document_head.php'?>
 <script src="scripts/drop/droparea.js"></script>
            <style>
                .droparea {
                    position:relative;
                    text-align: center;
                }
                .multiple {
                    position:relative;
                    height: 20px;
                }
                .droparea div, .droparea input, .multiple div, .multiple input {
                    position: absolute;
                    top:0;
                    width: 100%;
                    height: 100%;
                }
                .droparea input, .multiple input {
                    cursor: pointer; 
                    opacity: 0; 
                }
                .droparea .instructions, .multiple .instructions {
                    border: 2px dashed [URL=http://forum.iyinet.com/usertag.php?do=list&action=hash&hash=ddd]#ddd[/URL]
                    opacity: .8;
                }
                .droparea .instructions.over, .multiple .instructions.over {
                    border: 2px dashed [URL=http://forum.iyinet.com/usertag.php?do=list&action=hash&hash=000]#000[/URL]
                    background: [URL=http://forum.iyinet.com/usertag.php?do=list&action=hash&hash=ffa]#ffa[/URL]
                }
                .droparea .progress, .multiple .progress {
                    position:absolute;
                    bottom: 0;
                    width: 100%;
                    height: 0;
                    color: [URL=http://forum.iyinet.com/usertag.php?do=list&action=hash&hash=fff]#fff[/URL]
                    background: [URL=http://forum.iyinet.com/usertag.php?do=list&action=hash&hash=6b0]#6b0[/URL]
                }
                .multiple .progress {
                    width: 0;
                    height: 100%;
                }


                #areas { float: left;  }
                div.spot {
                    float: left;
                    margin: 0 7px 15px 5px;
                    width: 107px;
                    min-height: 107px;
                }
                .thumb {
                    float: left;
                    margin:0 20px 20px 0;
                    width: 140px;
                    min-height: 105px;
                }
                
            </style>
	<div id="pjax">
		<div id="wrapper" data-adminica-nav-top="3" data-adminica-nav-inner="2">
			<?php include 'includes/components/topbar.php'?>
			<?php include 'includes/components/sidebar.php'?>
			<?php include 'includes/components/stackbar.php'?></div><!-- Closing Div for Stack Nav, you can boxes under the stack before this -->

			<div id="main_container" class="main_container container_16 clearfix">
				<?php include 'includes/components/navigation.php'?>
				<div class="flat_area grid_16">
					<h2>Yeni İlan Ekle - ADIM 2
						
					</h2>
            
				</div>
				

				<div class="box grid_16">
					<div class="block">
						 <input type="file" class="droparea spot" name="xfile" data-post="includes/content/upload.php" data-width="107" data-height="107" data-crop="true"/>
                         <input type="file" class="droparea spot" name="xfile" data-post="includes/content/upload.php" data-width="107" data-height="107" data-crop="true"/>
                         <input type="file" class="droparea spot" name="xfile" data-post="includes/content/upload.php" data-width="107" data-height="107" data-crop="true"/>
                         <input type="file" class="droparea spot" name="xfile" data-post="includes/content/upload.php" data-width="107" data-height="107" data-crop="true"/>
                         <input type="file" class="droparea spot" name="xfile" data-post="includes/content/upload.php" data-width="107" data-height="107" data-crop="true"/>
                         <input type="file" class="droparea spot" name="xfile" data-post="includes/content/upload.php" data-width="107" data-height="107" data-crop="true"/>
                         <input type="file" class="droparea spot" name="xfile" data-post="includes/content/upload.php" data-width="107" data-height="107" data-crop="true"/>
                         <input type="file" class="droparea spot" name="xfile" data-post="includes/content/upload.php" data-width="107" data-height="107" data-crop="true"/>
                         <input type="file" class="droparea spot" name="xfile" data-post="includes/content/upload.php" data-width="107" data-height="107" data-crop="true"/>
                         <input type="file" class="droparea spot" name="xfile" data-post="includes/content/upload.php" data-width="107" data-height="107" data-crop="true"/>
                         <input type="file" class="droparea spot" name="xfile" data-post="includes/content/upload.php" data-width="107" data-height="107" data-crop="true"/>
					</div>
				
              </div>
                <div class="grid_16 box clearfix">
					<div class="indented_button_bar clearfix">
						<button class="dark on_dark" id="toggle_lines">
							<span>İLANIMI TAMAMLA</span>
						</button>
						<p>Butona bastığınızda <strong>ilanınız tamamlanır.</strong></p>
					</div>
				</div>
			</div>
          
		</div>
        

            <script>
            // Calling jQuery "droparea" plugin
            $('.droparea').droparea({
                'instructions': 'buyara sürükle yada tıkla',
                'init' : function(result){
                    //console.log('custom init',result);
                },
                'start' : function(area){
                    area.find('.error').remove(); 
                },
                'error' : function(result, input, area){
                    $('<div class="error">').html(result.error).prependTo(area); 
                    return 0;
                    //console.log('custom error',result.error);
                },
                'complete' : function(result, file, input, area){
                    if((/image/i).test(file.type)){
                        area.find('img').remove();
                        //area.data('value',result.filename);
                        area.append($('<img>',{'src': result.path + result.filename + '?' + Math.random()}));
                    } 
                    //console.log('custom complete',result);
                }
            });
            </script>
		<?php include 'includes/dialogs/dialog_welcome.php'?>
		<?php include 'includes/dialogs/dialog_logout.php'?>
<?php include 'includes/core/document_foot.php'?>


upload eden sayfa
Kod:
<?php

// Result object
$r = new stdClass();
// Result content type
header('content-type: application/json');


// Maximum file size
$maxsize = 10; //Mb
// File size control
if ($_FILES['xfile']['size'] > ($maxsize * 1048576)) {
    $r->error = "Max file size: $maxsize Kb";
}


// Uploading folder
$folder = 'files/';
if (!is_dir($folder))
    mkdir($folder);
// If specifics folder 
$folder .= $_POST['folder'] ? $_POST['folder'] . '/' : '';
if (!is_dir($folder))
    mkdir($folder);


// If the file is an image
if (preg_match('/image/i', $_FILES['xfile']['type'])) {

    $filename = $_POST['value'] ? $_POST['value'] :
            $folder . sha1(@microtime() . '-' . $_FILES['xfile']['name']) . '.jpg';
} else {

    $tld = split(',', $_FILES['xfile']['name']);
    $tld = $tld[count($tld) - 1];
    $filename = $_POST['value'] ? $_POST['value'] :
            $folder . sha1(@microtime() . '-' . $_FILES['xfile']['name']) . $tld;
}


// Supporting image file types
$types = Array('image/png', 'image/gif', 'image/jpeg');
// File type control
if (in_array($_FILES['xfile']['type'], $types)) {
    // Create an unique file name    
    // Uploaded file source
    $source = file_get_contents($_FILES["xfile"]["tmp_name"]);
    // Image resize
    imageresize($source, $filename, $_POST['width'], $_POST['height'], $_POST['crop'], $_POST['quality']);
} else
// If the file is not an image
    move_uploaded_file($_FILES["xfile"]["tmp_name"], $filename);


// File path
$path = str_replace('upload.php', '', $_SERVER['SCRIPT_NAME']);

// Result data
$r->filename = $filename;
$r->path = $path;
$r->img = '<img src="' . $path . $filename . '" alt="image" />';

// Return to JSON
echo json_encode($r);

// Image resize function with php + gd2 lib
function imageresize($source, $destination, $width = 0, $height = 0, $crop = false, $quality = 100) {
    $quality = $quality ? $quality : 100;
    $image = imagecreatefromstring($source);
    if ($image) {
        // Get dimensions
        $w = imagesx($image);
        $h = imagesy($image);
        if (($width && $w > $width) || ($height && $h > $height)) {
            $ratio = $w / $h;
            if (($ratio >= 1 || $height == 0) && $width && !$crop) {
                $new_height = $width / $ratio;
                $new_width = $width;
            } elseif ($crop && $ratio <= ($width / $height)) {
                $new_height = $width / $ratio;
                $new_width = $width;
            } else {
                $new_width = $height * $ratio;
                $new_height = $height;
            }
        } else {
            $new_width = $w;
            $new_height = $h;
        }
        $x_mid = $new_width * .5;  //horizontal middle
        $y_mid = $new_height * .5; //vertical middle
        // Resample
        error_log('height: ' . $new_height . ' - width: ' . $new_width);
        $new = imagecreatetruecolor(round($new_width), round($new_height));
        imagecopyresampled($new, $image, 0, 0, 0, 0, $new_width, $new_height, $w, $h);
        // Crop
        if ($crop) {
            $crop = imagecreatetruecolor($width ? $width : $new_width, $height ? $height : $new_height);
            imagecopyresampled($crop, $new, 0, 0, ($x_mid - ($width * .5)), 0, $width, $height, $width, $height);
            //($y_mid - ($height * .5))
        }
        // Output
        // Enable interlancing [for progressive JPEG]
        imageinterlace($crop ? $crop : $new, true);

        $dext = strtolower(pathinfo($destination, PATHINFO_EXTENSION));
        if ($dext == '') {
            $dext = $ext;
            $destination .= '.' . $ext;
        }
        switch ($dext) {
            case 'jpeg':
            case 'jpg':
                imagejpeg($crop ? $crop : $new, $destination, $quality);
                break;
            case 'png':
                $pngQuality = ($quality - 100) / 11.111111;
                $pngQuality = round(abs($pngQuality));
                imagepng($crop ? $crop : $new, $destination, $pngQuality);
                break;
            case 'gif':
                imagegif($crop ? $crop : $new, $destination);
                break;
        }
        @imagedestroy($image);
        @imagedestroy($new);
        @imagedestroy($crop);
    }
}

?>
 

metadige

0
İyinet Üyesi
Katılım
23 Aralık 2005
Mesajlar
354
Reaction score
4
PHP:
// Result data 
$r->filename = $filename; 
$r->path = $path; 
$r->img = '<img src="' . $path . $filename . '" alt="image" />';  

// Return to JSON
 echo json_encode($r);

Şu kısmı

PHP:
// Result data 
$r->filename = $filename; 
$r->path = $path; 
$r->img = '<img src="' . $path . $filename . '" alt="image" />';  


//burada önce veritabanı bağlantını yapman veya varsa bağlantı dosyanı include etmen gerekli

$resim = str_replace($folder,'',$filename);
$sorgu = 'insert into tablo_adi set fotograf_adi="'.$resim.'"';
mysql_query($sorgu) or trigger_error(mysql_error(),E_USER_ERROR);

// Return to JSON 
echo json_encode($r);

şu şekilde yaparsan olması lazım, denemediğim için hata olursa yazarsın.
Yalnız yazdığım kısma veritabanı bağlantını yapmayı ve sorguda ki tablo_adi ve fotograf_adi bölümünü kendi veritabanında ki alanlar ile değişmeyi unutma.
 

reflex073

0
İyinet Üyesi
Katılım
20 Aralık 2011
Mesajlar
40
Reaction score
0
şimdi metadige şöy düşünelim bu ajax ile yüklüyor resimleri. kullanıcı onay vermeden direk oraya ben veritabanı kayıt işlemi yparsam kullanıcı fotoğraf değiştirse bile değiştirdiğinide ekleyecektir. yani benim ordan sadece isimleri çekmem lazımki butona bastığında isimleri db ye yazıyım
 

Türkiye’nin ilk webmaster forum sitesi iyinet.com'da forum üyeleri tarafından yapılan tüm paylaşımlardan; Türk Ceza Kanunu’nun 20. Maddesinin, 5651 Sayılı Kanununun 4. maddesinin 2. fıkrasına göre, paylaşım yapan üyeler sorumludur.

Backlink ve Tanıtım Yazısı için iletişime geçmek için Skype Adresimiz: .cid.1580508955483fe5

Üst