güvenlik kodu doğruysa dosyayı otomatikmen indirmesini istiyorum. kodlar şöyle.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1254">
<script language="JavaScript" type="text/javascript" src="ajax_captcha.js"></script>
</head>
<body>
<form action="javascript:get(document.getElementById('myform'));" name="myform" id="myform">
<p align="center">
<img id="imgCaptcha" src="create_image.php" onclick="setTimeout('refreshimg()', 300); return false;" alt="Degistir"/>
<input id="txtCaptcha" type="text" name="txtCaptcha" value="" maxlength="10" size="10" autocomplete="off"/>
<br>
<font face="Verdana" size="2">Ödevi İndirmek İçin Güvenlik Kodunu Giriniz..</font><br><input type="image" src="indir.jpg" name="button" value="Submit"
onclick="javascript:get(this.parentNode);">
<input type="hidden" name="link_id" value="5545">
</p>
</form>
<center><div name="myspan" id="myspan"></div><center>
</body>
</html> var http_request = false;
function makeRequest(url, parameters) {
http_request = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
// set type accordingly to anticipated content type
//http_request.overrideMimeType('text/xml');
http_request.overrideMimeType('text/xml; charset=windows-1254');
}
} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http_request) {
alert('Cannot create XMLHTTP instance');
return false;
}
http_request.onreadystatechange = alertContents;
http_request.open('GET', url + parameters, true);
http_request.send(null);
}
function alertContents() {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
//alert(http_request.responseText);
result = http_request.responseText;
document.getElementById('myspan').innerHTML = result;
//Get a reference to CAPTCHA image
img = document.getElementById('imgCaptcha');
//Change the image
img.src = 'create_image.php?' + Math.random(); // Search for new image
document.getElementById('txtCaptcha').value=''; //Reset input Captcha after succes return
} else {
alert('There was a problem with the request.');
}
}
}
function get(obj) {
var getstr = "?" +
"&link_id=" + encodeURI( document.getElementById("link_id").value) +
"&txtCaptcha=" + encodeURI( document.getElementById("txtCaptcha").value) ;
makeRequest('get.php', getstr);
}
// IMAGE REFRESHING
function refreshimg()
{
//Get a reference to CAPTCHA image
img = document.getElementById('imgCaptcha');
//Change the image
img.src = 'create_image.php?' + Math.random();
}buda php kodu<?php
session_start();
$id = $_GET[link_id];
if ( ($_GET["txtCaptcha"] == $_SESSION["security_code"]) && (!empty($_GET["txtCaptcha"]) && !empty($_SESSION["security_code"])) ) {
header('Refresh: 10; url=1.zip');
} else {
echo '<font face="Verdana" size="1" color="#FF0000">Guvenlik Kodunu Yanlis Girdiniz.Lutfen Tekrar Deneyiniz</font>';
}
?>kod doğruysa dosyanın otomatik inmesini istiyorum. ajax ile ne yönlenme çalışıyor nede header attachment kodu. girilen güvenli kod doğru ise aşağıdaki kodları çalışırmak istiyorum fakat ajaxta çalışmıyor?
header('Content-Type: application/zip);
header('Content-Disposition: attachment; filename="1.zip"');
header("Content-Type: application/download");
yardım ederseniz sevinirim..