나는 그것을 수행하는 데 필요한 것보다 상대적으로 쉬운 프로젝트를 진행 해왔다.이미지 업로드 PHP
나는 의사와 환자 사이에있는 전체 웹 사이트를 만들었습니다. 이미지를 업로드하고 검색하는 데 심하게 붙어 있습니다! 여기
는 ..<?php session_start();
$un = "xxx";
$pw = "xxx";
$hn = "xxx";
$dbhandle = mysql_connect($hn, $un, $pw) or die("Couldn't connect to the database");
mysql_set_charset('utf8');
$selected = mysql_select_db("dsnnet_login", $dbhandle);
$myusername = $_SESSION['snamed'];
$target_dir = "uploaded/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$sql = mysql_query("UPDATE docTable set photoname='$target_file' WHERE Username= '$myusername'");
$uploadOk = 1;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
// Check if image file is a actual image or fake image
if(isset($_POST["submit"])) {
$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
if($check !== false) {
echo "File is an image - " . $check["mime"] . ".";
$uploadOk = 1;
} else {
echo "File is not an image.";
$uploadOk = 0;
}
}
// Check if file already exists
// Check file size
if ($_FILES["fileToUpload"]["size"] > 500000) {
echo "Sorry, your file is too large.";
$uploadOk = 0;
}
// Allow certain file formats
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
&& $imageFileType != "gif") {
echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
$uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
echo "Sorry, your file was not uploaded.";
// if everything is ok, try to upload file
} else {
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
echo "The file ". basename($_FILES["fileToUpload"]["name"]). " has been uploaded.";
} else {
echo "Sorry, there was an error uploading your file.";
}
}
header("location: docp.php");
?>
내가 작성했던 코드와 "작업 페이지는"다음과 같다 :
<?php session_start();
$un = "xxx";
$pw = "xxx";
$hn = "xxx";
$dbhandle = mysql_connect($hn, $un, $pw) or die("Couldn't connect to the database");
mysql_set_charset('utf8');
$selected = mysql_select_db("dsnnet_login", $dbhandle);
$myusername = $_SESSION['snamed'];
$target_dir = "uploaded/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$sql = mysql_query("UPDATE docTable set photoname='$target_file' WHERE Username= '$myusername'");
$uploadOk = 1;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
// Check if image file is a actual image or fake image
if(isset($_POST["submit"])) {
$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
if($check !== false) {
echo "File is an image - " . $check["mime"] . ".";
$uploadOk = 1;
} else {
echo "File is not an image.";
$uploadOk = 0;
}
}
// Check if file already exists
// Check file size
if ($_FILES["fileToUpload"]["size"] > 500000) {
echo "Sorry, your file is too large.";
$uploadOk = 0;
}
// Allow certain file formats
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
&& $imageFileType != "gif") {
echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
$uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
echo "Sorry, your file was not uploaded.";
// if everything is ok, try to upload file
} else {
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
echo "The file ". basename($_FILES["fileToUpload"]["name"]). " has been uploaded.";
} else {
echo "Sorry, there was an error uploading your file.";
}
}
header("location: docp.php");
?>
누구나 알아낼 수 있습니까? 나는 포기하지 않을거야 지금은 적어도 4 일 동안 노력했습니다 .. .. 나는
너희들 : 환호
당신이 오류를 얻고있다. 또는 죄송합니다. 파일이 너무 큽니다. –