2017-06-04 32 views
-2

我得到這個錯誤,當我在圖像共享服務工作,雖然我嘗試上傳圖像沒有任何反應,沒有圖像獲取上傳,請你可以在代碼上添加代碼,使每個圖像上傳存儲在一個文件夾中的代碼? 我的服務代碼:無法打開流:在第26行的C: xampp htdocs imgfox upload.php中無效參數,請嘗試上傳no/.. image。

<html> 
<head> 
    <title>upload images</title> 
</head> 
<body> 

<form action="upload.php" method="POST" enctype="multipart/form-data"> 
    image: 
    <input type="file" name="image"> <input type="submit" value="Upload"> 
</form> 

<?php 
// connect to database 
mysql_connect("localhost","root","") or die(mysql_error()); 
mysql_select_db("meinimages") or die(mysql_error()); 

// file properties 
$file = $_FILES['image']['tmp_name']; 

if (!isset($file)) 
    echo "please choose an image."; 
else 
{ 
$image = addslashes(file_get_contents($_FILES['image']['tmp_name'])); 
$image_name = addslashes($_FILES['image']['name']); 
$image_size = getimagesize($image); 

if ($image_size==FALSE) 
    echo "you try upload no/..image."; 
else 
{ 
    if (!$insert = mysql_query("INSERT INTO store VALUES ('','$image_name','$image')")) 
     echo "problem while upload $image."; 
    else 
    { 
     $lastid = mysql_insert_id(); 
     echo "image is uploaded.<p />your image:<p /><img src=get.php?id=$lastid>"; 
    } 



} 

} 
+1

另請閱讀[爲什麼不應該在PHP中使用mysql_ *函數?](https://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php)安全地使用MySQL。 –

+0

我應該替換或更改什麼代碼 – jack

+0

使用mysqli而不是mysql – AVI

回答

0

只需使用此代碼〜

<input type="file" name="uploadsrc" /> 

<?php 
move_uploaded_file("uploads/".$_FILES["uploadsrc"]["name"]); 
?> 

無需喊出你的問題大家都可以看到它!

相關問題