Jump to content

wannes

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Posts posted by wannes

  1. I'm trying to upload a file using ajax, but I have some problems.

    First I'll show the code :

     

    HTML

    <form id="foto" action="index.php?action=send" method="post" enctype="multipart/form-data">
    	<fieldset>
    		<label>Kleur</label>
    		<input id="Binded" type="text" value="ffffff" />
        		<br />
    		<label>Upload foto</label>
            	<input id="file" type="file" name="upload" id="upload"/>
            	<a href="index.php?action=foto" id="uploaden">uploaden</a>
    	</fieldset>
    <fieldset id="audioplayer">
    <h3>Kies een soundtrack</h3>
    <ol id="lijst">
          	<li id="een" class="active"><a href="assets/audio/Gayla_Peevey-I_Want_a_Hippopotamus_For_Christmas.mp3">Gayla Peevey - I Want a Hippopotamus For Christmas</a>
          	<img class="mute" src="assets/images/mute.png" width="30" height="30" alt="mute"/></li>
          	<li id="twee"><a href="assets/audio/SouthFamilyXmas2005-NuttinForChristmas.mp3">South Family - Nuttin for Christmas</a>
          	<img class="mute" src="assets/images/mute.png" width="30" height="30" alt="mute"/></li>
          	<li id="drie"><a href="assets/audio/southpark_merry_christmas.mp3">South Park - Merry Christmas</a>
          	<img class="mute" src="assets/images/mute.png" width="30" height="30" alt="mute"/></li>
          	</li>
       	</ol>
       	
       	<audio id="audio" preload="auto" autobuffer autoplay src="assets/audio/Gayla Peevey - I Want a Hippopotamus For Christmas.mp3">
    </audio>
       	
    </fieldset>
    <fieldset id="emailen">
    <h3>Email een vriend</h3>
    <br />
    <input type="email" name="email"  placeholder="Email" required="true" />
    <input type="submit" name="verstuur" id="verstuur" value="Verstuur" />
    </fieldset>
    </form>

     

    PHP

    function getAjaxContent(){
    
    	global $smarty;
    
    	$dir = "uploads";
            $tempdir = $_FILES['upload']["tmp_name"];
           	$realdir = $dir."/".$_FILES["upload"]["name"];
            //$fotoTonen = '<img src="'.$realdir.'" alt="foto upload">';
            //$toonFoto = true;
    
            if(!is_dir($dir)){
                mkdir($dir);
            }
    
            move_uploaded_file($tempdir, $realdir);
    
    	var_dump($_FILES);
    
    	return  $smarty->fetch('kaart-ajax.htm');
    
    }

    Here I get the error <b>Notice</b>:  Undefined index:  upload in <b>/Applications/MAMP/htdocs/2011-2012/kerstkaart/includes/index.php</b> on line <b>16</b><br /> and the var_dump gives an empty array

     

    AJAX

    $('input[name=foto]').change(function(event){
        	
        	$.ajax({
            url:"index.php?action=foto",
            data: $('input[type=file]').val(),
            type: "POST",
            timeout: 3000,
            error: function(jqXHR, textStatus,errorThrown){
                alert("probleem met ajax "+textStatus);
            },
            success: function(data, textStatus, jqXHR){
    
    
                alert("jaja "+data);
    
    		canvas.width = canvas.width;
    		context.drawImage(image, 0, 0);
    		image.src = 'uploads/'+data;
           
            }
         	});
        	
        	
        	event.preventDefault();
        	
        });

     

    What I try to do here is getting the value of the selected file and redraw my canvas ( HTML5 ) so that the chosen pic is the background.

    The file i upload to test is a gif of 4KB, so not that big.

     

    Can anyone help me with this confusing problem ?

    Thanks,

  2. My apologize if this should be here since this involves SQL.

     

    My user can register himself ( just an email ) to a mail list.

    He will get a mail after that, but the message in the mail should differ:

    If there are under 100 people in the DB he should get something like " you are one of the 100 first people ", if there are more then 100 people it should say " sorry, to late ".

     

    I can seem to get it to work so help would be awesome

    ( ps, I kinda need an anwser fast :s )

    $sqlInsert = "INSERT INTO j5_maillist (email) VALUES('$email')";
    
            $sql = "SELECT COUNT(email) FROM j5_maillist AS aantalEmails";
            $result = mysql_query($sql);
    
    
            if( mysql_num_rows($result) <= "3" ){
                 $message = 'you are one of the 100 first people  ';
        } else {
                 $message = 'sorry, to late  ';
    }
    
            $to      = $email;
            $subject = 'Nihonto Appreciation Day';
            $headers  = 'MIME-Version: 1.0' . "\r\n";
            $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    
                // Additional headers
            $headers .= 'To: '.$email.'' . "\r\n";
            $headers .= 'From: Nihonto Appreciation Day' . "\r\n";
    
            mail($to, $subject, $message, $headers);
    
            return mysql_query($sql);

     

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.