Jump to content
php.lv forumi

ziedinjsh

Reģistrētie lietotāji
  • Posts

    789
  • Joined

  • Last visited

Posts posted by ziedinjsh

  1. Esi aizmirsis indeksu masīva elementiem. Iemet pašā augšā un salīdzini ar savu rakstīto.

    echo '<pre>';

    print_r($_FILES);

    echo '</pre>';

    Array( [pic] => Array ( [name] => Array ( [0] => 1.jpg ) [type] => Array ( [0] => image/jpeg ) [tmp_name] => Array ( [0] => D:\Server\xampp\tmp\phpEB37.tmp ) [error] => Array ( [0] => 0 ) => Array ( [0] => 532748 ) ))

    Image is to big - 5Mb

     

    Notice: Array to string conversion in D:\Server\xampp\htdocs\projekti\up\index.php on line 116

    Array > 5242881Onely image file

  2. HTML

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Multiple File Upload with jQuery and PHP</title>
    <script src="jquery-1.8.1.min.js" type="text/javascript" language="javascript"></script>
    <script src="jquery.MultiFile.js" type="text/javascript" language="javascript"></script>
    </head>
    <body>
    <form action="index.php" method="post" enctype="multipart/form-data">
    <input type="file" name="pic[]" class="multi" multiple />
    <input type="submit" name="upload" value="Upload" />
    </form>
    </body>
    </html>
    

  3. malinens paldies! Mēģinot augšupielādēt: Image is to big - 5Mb

     

    Notice: Array to string conversion in D:\Server\xampp\htdocs\projekti\up\index.php on line 112

    Array < 5242881Onely image file

  4. Sveiki.

     

    šis ir kods:

    if(isset($_POST['upload']))
    {
    
    foreach ($_FILES["pic"]["error"] as $key => $error){
       	if ($error == UPLOAD_ERR_OK){
    if(isset($_FILES['pic']['name']) && !empty($_FILES['pic']['name'])){
    $name = $_FILES['pic']['name'];
    $tmp_name = $_FILES['pic']['tmp_name'];
    $file_size = $_FILES['pic']['size'];
    $file_size_limit = 5242881;
    $type = $_FILES['pic']['type'];
    $types_allowed = array('image/jpeg', 'image/jpg', 'image/gif', 'image/png');
    $location = 'uploads/';
    $normal = 200;
    $small = 50;
    
    $errors = array();
    $counter = 0;
    do{
     $rand_filename = rand(10000,99999).'.jpeg';
     $uniq_name = $location.$rand_filename;
     $location_contents = scandir($location);
     $counter++;
     if($counter>99999){
      echo 'Can not find a unique name.<br/>';
      $errors[] = '1';
     }
    }
    while(in_array($rand_filename, $location_contents));
    
    
    
    if($file_size>$file_size_limit){
     echo 'Image is to big - 5Mb<br/>';
     $errors[] = '1';
    }
    
    
    if(!in_array($type, $types_allowed)){
     echo 'Onely image file';
     $errors[] = '1';
    }
    
    
    if(empty($errors)){
     if(move_uploaded_file($tmp_name, $uniq_name)){
    
    
    	function resize_image($width_height, $folder_path){
    
     	global $location, $rand_filename, $image_path;
    
     	if(isset($rand_filename, $location)){
    
      	$image_path = $location.$rand_filename;
    
    
      	if(file_exists($image_path)){
    
    
       	$image_size = getimagesize($image_path);
       	$image_width = $image_size[0];
       	$image_height = $image_size[1];
    
       	if($old_image = @imagecreatefromjpeg($image_path)){
    
       	}elseif($old_image = @imagecreatefromgif($image_path)){
    
       	}else if($old_image = @imagecreatefrompng($image_path)){
    
       	}
       	else{
        	echo 'Image upload error.<br/>';
        	return false;
        	break;
       	}
    
    
        	$offset = strpos($rand_filename, '.');
              	$result_image_name = $folder_path.$rand_filename;
    
    
    
       	if($image_height>$image_width){
        	$greater_axe = $image_height;
        	$smaller_axe = $image_width;
       	}
       	else{
        	$greater_axe = $image_width;
        	$smaller_axe = $image_height;
       	}
    
    
    
       	$x = ($image_width-$smaller_axe)/2;
       	$y = ($image_height-$smaller_axe)/2;
    
    
    
       	$image_croped = imagecreatetruecolor($width_height, $width_height);
       	if(@!imagecopyresampled($image_croped, $old_image, 0, 0, $x, $y, $width_height, $width_height, $smaller_axe, $smaller_axe)){
       	echo 'Function error.<br/>';
       	return false;
       	break;
       	}
    
    
    
       	if(@imagejpeg($image_croped, $result_image_name)){
    
        	return true;
       	}
       	else{
    
        	echo 'Image upload error.<br/>';
        	return false;
        	break;
       	}
      	}
      	else{
       	echo 'Picture does not exist.<br/>';
       	return false;
      	}
     	}
     	else{
    
      	echo 'Upload error.<br/>';
      	return false;
     	}
    
    	}
    
    
    	if(resize_image($normal, 'uploads/normal/') && resize_image($small, 'uploads/small/')){
    
    	echo 'Viss ok!';
    
    
    
    	}
    	else{
     	//unlink($image_path);
    	}
    
    
    }
     else{
      echo 'Function error, please try later.<br/>';
     }
    }
    }else{
    echo 'Please select image';
    }
    
       	}
    }
    
    }
    

     

    Izvēlos bildi, palaižu kodu un man izmet kļūdu ziņojumus:Image is to big - 5Mb un Onely image file. Bilde ir 2.6 mb liela un ir jpg formāta bilde

  5. Labs rīts!

    Vakar pirms gulētiešanas iedomājos vai kkas jau gatavs vai ir kads tuteriālis šādai lietai:

     

    Datubāzē tiek ierakstīts šādas lietas:

     

    id, title, size, price, views un buys

     

    uzspiežot uz title parādās prdoukts atsevišķi un tur ir links buy kuram vajadzētu pildīt šādu funkciju:

     

    uzspiežot uz linka, viņš atver paypal maksājuma lapu kur ir norādītais saņēmēja epasts, manā datubāzē norādītā summa un prdukta id, lai katru reizi pievienojot produktu nav jātaisa atsevišķa buy now poga.

     

    Un kā vēl ir ar to respond? Kad tiek veikts maksājums viņš nosūta atpakaļ uz lapu un lejupielādē produktu. Šādā gadījumā vajadzētu arī katru reizi unikālu linku lai nevar lejupielādēt tāpat.

  6. lapā parāda vienu plejeri, bet source failā ir divi.. tad tikai vajag to #player kkā uztaisīt lai liktu klāt arī ieraksta id id="player'.$data['id'].'" kkā tā

     

    <script type='text/javascript'>
    $(window).load(function(){
       	var url="http://soundcloud.com/epic8/epic8-will-never-be-the-same";
       	$.ajax({
       	type: "GET"
       	,dataType: "json"
       	,data: {
               	jsonp : "output"
               	,url: url
               	,format: "json"
               	,iframe: "true"         
       	}
       	,url : "http://soundcloud.com/oembed"
       	,success:
               	function(data) {
               	$('#player').html(data.html);
               	}                             
       	});
    });
    </script>
    <div id="player"></div>
    <script type='text/javascript'>
    $(window).load(function(){
       	var url="http://soundcloud.com/epic8/epic8-cave";
       	$.ajax({
       	type: "GET"
       	,dataType: "json"
       	,data: {
               	jsonp : "output"
               	,url: url
               	,format: "json"
               	,iframe: "true"         
       	}
       	,url : "http://soundcloud.com/oembed"
       	,success:
               	function(data) {
               	$('#player').html(data.html);
               	}                             
       	});
    });
    </script>
    <div id="player"></div>
    

  7. Sveiki! Datubāzē man ir divi ieraksti bet rāda tikai vienu

    php:

     

    $music = mysql_query("select * from music where uid='".$data['id']."'") or die(mysql_error());
    while($data = mysql_fetch_array($music)){
    $link = $data['link'];
    ?>
    
    <script type="text/javascript" src="js/jquery-1.8.0.min.js"></script>
    <script type='text/javascript'>
    $(window).load(function(){
       	var url="<?php echo $link; ?>";
       	$.ajax({
       	type: "GET"
       	,dataType: "json"
       	,data: {
               	jsonp : "output"
               	,url: url
               	,format: "json"
               	,iframe: "true"         
       	}
       	,url : "http://soundcloud.com/oembed"
       	,success:
               	function(data) {
               	$('#player').html(data.html);
               	}                             
       	});
    });
    </script>
    <div id="player"></div>
    
    <?php
    }
    

     

    kapēc tā?

  8. mysql_query("insert into links (title, desc, link, img_to_upload, date) values ('$title', '$desc', '$link', '$photo', '$date')") or die(mysql_error());
    

    visu laiku bļauj

    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 ''title', 'desc', 'link', 'img_to_upload', 'date') values ('besiiiiii ' at line 1

     

    kā tad vēl var saglabāt???

  9. mysql_query("insert into links (title, desc, link, img_to_upload, date) values ('$title', '$desc', '$link', '$photo', '$date')") or die(mysql_error());
    

    visu laiku bļauj

    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 ''title', 'desc', 'link', 'img_to_upload', 'date') values ('besiiiiii ' at line 1

     

    kā tad vēl var saglabāt???

  10. <?php
    
    function cloud($link){
    ?>
    <head>
    <script type='text/javascript' src='http://code.jquery.com/jquery-1.8.0.min.js'></script>
    <script type='text/javascript'>
    $(window).load(function(){
    var url="<?php echo $link; ?>";
    $.ajax({
       	type: "GET"
       	,dataType: "json"
       	,data: {
           	jsonp : "output"
           	,url: url
           	,format: "json"
           	,iframe: "true"           
       	}
       	,url : "http://soundcloud.com/oembed"
       	,success:
           	function(data) {
              	$('#player').html(data.html);
           	}                               
    });
    });
    </script>
    </head>
    <div id="player"></div>
    <?php
    }
    
    function media_check($status_text){
    $matches = array(
    '/((https?|ftp).*(gif|png|jpg|jpeg))/i',
    '%<a(.*)(?:href="https?://)?(?:www\.)?(?:youtu\.be/|youtube\.com(?:/embed/|/v/|/watch\?v= ))([\w\-]{10,12})(?:)([\w\-]{0})\b%x',
    '%(?:https?://)(?:www\.)?soundcloud\.com/([\-a-z0-9_]+/[\-a-z0-9_]+)%im',
       	);
    
    $replacements = array(
    '<a href="$1" target="_blank"><img src="$1" style="width:400px;"/></a>',
    '<iframe style="width:500px;height:300px;border:0;" src="http://www.youtube-nocookie.com/embed/$2"></iframe>',
    cloud('http://soundcloud.com/$1')
    );
    
    $status_text = preg_replace($matches, $replacements, $status_text);
    
     return $status_text;
    }
    ?>
    

    Neiet, jo url parādās kā http://soundcloud.com/$1 iekš cloud('') nestrādā $1;

  11. Sveiki!

    Kā panāk tādu lietu kā:

     

    test.php: ir if funkcija kas pārbauda vai ir tas kam vajag būt vai nav. kā var nosūtīt no if funkcijas informāciju uz citu php failu kur tas tik parādīts iekš div ar jquery?

     

    1.php if funkcija nočeko ir vai nav

    2. tajā pašā brīdi tas tiek parādīts iekš 2.php ir vai nav at jquery funkciju

×
×
  • Create New...