2015-09-17 24 views
0

我已經創建了HTML像一個iframe:獲得404未找到錯誤,而分配的PHP文件作爲源,即使我的PHP文件有

<p class="input-block"> 
    <iframe src="php/image.php" height="50" width="100" scrolling="no" frameborder="0" marginheight="0" marginwidth="0" class="captcha-frame" name="captcha_image_frame"></iframe> 
</p> 

這個HTML文件位於inetpub/wwwroot/Site下,並有一個圖像.php文件在inetpub/wwwroot/Site/php之下。然而,當我進入的HTML網頁,我看到控制檯上的錯誤:

GET http://demo.com/php/image.php 404 (Not Found)

如果我偶然SRC爲「http://localhost/php/image.php」,然後我得到的錯誤:

GET http://localhost/php/image.php net::ERR_CONNECTION_REFUSED

注:當我進入http://demo.com/php/image.php,我也沒有找到錯誤,但我希望不會得到它,因爲有一個image.php下的php文件夾:(

問題是,我怎麼能設法將image.php分配給iframe源。如果有人幫忙,我很感激。

謝謝!

*演示不是原始域名。

編輯: image.php內容:

<?php 

session_start(); 
header("(anti-spam-content-type:) image/png"); 

$enc_num = rand(0, 9999); 
$key_num = rand(0, 16); 
$hash_string = substr(md5($enc_num), $key_num, 5); 
$hash_md5 = md5($hash_string); 

$_SESSION['verify'] = $hash_md5; 
// Verification Image Background Selection 

$bgs = array('1.png'); 
$background = array_rand($bgs, 1); 

// Verification Image Variables 

$img_handle = imagecreatefrompng($bgs[$background]); 
$text_colour = imagecolorallocate($img_handle, 255, 255, 255); 
$font_size = 5; 

$size_array = getimagesize($bgs[$background]); 
$img_w = $size_array[0]; 
$img_h = $size_array[1]; 

$horiz = round(($img_w/2) - ((strlen($hash_string) * imagefontwidth(5))/2), 1); 
$vert = round(($img_h/2) - (imagefontheight($font_size)/2)); 

// Make the Verification Image 

imagestring($img_handle, $font_size, $horiz, $vert, $hash_string, $text_colour); 
imagepng($img_handle); 

// Destroy the Image to keep Server Space 

imagedestroy($img_handle); 
+0

服務器機器正在使用Windows 8 –

+0

要顯示驗證碼? @Eray –

+0

是的,我在做@Subin –

回答

0

你所得到的錯誤是因爲80端口被其他應用程序使用。 This link會幫助你。如果Skype正在運行,請更改Skype設置並重新安裝服務器。

所以顯示驗證碼,我就這樣,通過將圖像數據URL.in HTML而不是iframe中,直接使用img標籤

<img src="./php/image.php" /> 

在PHP如下

<?php 
header ('Content-type: image/png'); 
$im = @imagecreatefrompng("./1.png"); 
imagepng($im, NULL, 0); 
imagedestroy($im); 
?> 
+0

好,仍然得到:GET http://demo.ca/php/image.php 404(未找到) –

+0

@Eray替換您的image.php –

+0

@Eray錯誤404是因爲一些其他應用程序使用您的端口80 –

相關問題