2012-09-16 3 views
1

사용자 이름, 암호, 이름, 성, 나이 및 프로필 사진을 저장할 수있는 자신의 프로필 시스템을 만들었습니다.서버에 시스템 문제 업로드

이 프로세스를 통해 이미지를 업로드하는 데 문제가 있습니다. 코드에 오류가 발생하여 이유를 이해할 수 없습니다. 영어에 대한 사과, 나는 덴마크에서 오전 (참고 : 편집기 무료 번역) 여기

그것은 나타납니다 내 코드

<?php 
    include ("inc/db/db.php"); 
    if (isset($_POST["godkendt_bruger"])) 
    { 
     $query = 'SELECT NULL FROM `bruger` WHERE `brugernavn` = ?'; 
     if ($stmt = $mysqli->prepare($query)) 
     { 
      $stmt->bind_param('s', $brugernavn); 
      $brugernavn = $_POST["brugernavn"]; 
      $stmt->execute(); 
      $stmt->store_result(); 
      $count = $stmt->num_rows; 
      $stmt->close(); 

      if ($count > 0) 
      { 
       $user_found = 1; 
      } 
     } 

     if (!isset($user_found)) 
     { 
      if ($_POST["pass"] != $_POST["gentag"]) 
      { 
       $errors = 1; 
       echo "<li id=\"check_not\">Angive ens password på siden..</li>"; 
      } 

      if (empty($_POST["pass"]) && empty($_POST["gentag"])) 
      { 
       $errors = 1; 
       echo "<li id=\"check_not\">Angive et password på siden..</li>"; 
      } 

      if (empty($_POST["navn"])) 
      { 
       $errors = 1; 
       echo "<li id=\"check_not\">Angive et Fornavn</li>"; 
      } 

      if (empty($_POST["efternavn"])) 
      { 
       $errors = 1; 
       echo "<li id=\"check_not\">Angive et Efternavn</li>"; 
      } 

      if (!isset($errors)) 
      { 
       $pb = null; 
       include "inc/img/class.upload.php"; 
       $handle = new Upload($_FILES["file"]); 

       if ($handle->uploaded) 
       { 
        //lidt mere store billeder 
        $handle->image_resize = true; 
        $handle->image_ratio_y = true; 
        $handle->image_x = 220; 
        $handle->Process("profil/store"); 

        //til profil billede lign.. 
        $handle->image_resize = true; 
        $handle->image_ratio_crop = true; 
        $handle->image_y = 115; 
        $handle->image_x = 100; 
        $handle->Process("profil"); 

        //til profil billede lign.. 
        $handle->image_resize = true; 
        $handle->image_ratio_crop = true; 
        $handle->image_y = 75; 
        $handle->image_x = 75; 
        $handle->Process("profil/lille"); 
        $pb = $handle->file_dst_name; 
       } 
       else 
       { 
        echo 'Der opstod en fejl i erklæringen: - upload ' . $mysqli->error; 
       } 
      } 

      //Lukker $errors 
      if (!isset($user_found)) 
      { 
       $query = 'INSERT INTO `bruger` ' 
         . '(`Brugernavn`, `password`, `profilbillede`, ' 
         . '`navn`, `efternavn`, `alder`) ' 
         . 'VALUES (?, ?, ?, ?, ?, ?)'; 
       if ($stmt = $mysqli->prepare($query)) 
       { 

       $stmt->bind_param(
        'sssssi', 
        $brugernavn, 
        $password, 
        $profilbillede, 
        $navn, 
        $efternavn, 
        $alder 
       ); 

       $brugernavn = $_POST["brugernavn"]; 
       $password  = $_POST["pass"]; 
       $profilbillede = $pb; 
       $navn   = $_POST["navn"]; 
       $efternavn  = $_POST["efternavn"]; 
       $alder   = $_POST["alder"]; 

       $stmt->execute(); 
       $stmt->close(); 

      } 
      else 
      { 
       /* Der er opstået en fejl */ 
       echo 'Der opstod en fejl i erklæringen til ligge i databasen: ' . $mysqli->error; 
      } 
     } 
    } 
    else 
    { 
     echo "<li id=\"check_not\">Dette brugernavn er optaget!!</li>"; 
    } 
} 
else 
{ 
    echo "<li id=\"check_opret\">Indtast dine oplysninger herunder for at opret en bruger </a></li>"; 
} 

?> 

입니다 오류가이 블록

if ($handle->uploaded) 
{ 
    //lidt mere store billeder 
    $handle->image_resize = true; 
    $handle->image_ratio_y = true; 
    $handle->image_x = 220; 
    $handle->Process("profil/store"); 

    //til profil billede lign.. 
    $handle->image_resize = true; 
    $handle->image_ratio_crop = true; 
    $handle->image_y = 115; 
    $handle->image_x = 100; 
    $handle->Process("profil"); 

    //til profil billede lign.. 
    $handle->image_resize = true; 
    $handle->image_ratio_crop = true; 
    $handle->image_y = 75; 
    $handle->image_x = 75; 
    $handle->Process("profil/lille"); 
    $pb = $handle->file_dst_name; 

} 
else 
{ 
    echo 'Der opstod en fejl i erklæringen: - upload ' . $mysqli->error; 
} 

오류에있는 다음과 같습니다 : 결과가 적용되지 않습니다 : - ()에 선언에 오류가 있습니다. 그 밖의 것은 없습니다. 데이터는 데이터베이스에 저장되지 않습니다.

This my html her;

<form name="opret_bruger" method="post" action="#" enctype="multipart/form-data"> 
<tr> 
    <td><p>Brugernavn</p></td> 
    <td><input type="text" name="brugernavn"></td> 
</tr> 
<tr> 
    <td><p>Password</p></td> 
    <td><input type="password" name="pass"></td> 
</tr> 
<tr> 
    <td><p>Password gentag</p></td> 
    <td><input type="password" name="gentag"></td> 
</tr> 
<tr> 
    <td><p>Fornavn</p></td> 
    <td><input type="text" name="navn"></td> 
</tr> 
<tr> 
    <td><p>Efternavn</p></td> 
    <td><input type="text" name="efternavn"></td> 
</tr> 
    <tr> 
    <td><p>Alder</p></td> 
    <td> 
     <select name="alder_1"> 
    <?php 
    if ($stmt = $mysqli->prepare('SELECT `alder` FROM `alder`')) { 
     $stmt->execute(); 

     /* Bind resultatet */ 
     $stmt->bind_result($alder); 

     /* Hent rækker og udskriv data */ 
     while ($stmt->fetch()) { 
     ?> 
      <option><?php echo $alder;?></option> 
     <?php 
     } 

      /* Luk statement */ 
      $stmt->close(); 

     } else { 
      /* Der er opstået en fejl */ 
      echo 'Der opstod en fejl i erklæringen: ' . $mysqli->error; 
     } 
     ?> 
     </select> 
    </td> 
</tr> 
<tr> 
    <td><p>Upload Profilbillede</p></td> 
    <td><input type="file" name="profilbillede"></td> 
</tr> 
<tr> 
    <td></td> 
    <td><input type="submit" name="godkendt_bruger"></td> 
</tr> 
</form> 

이미지를 저장할 수 있도록 제안 사항이 있으면 환영합니다. 코드를 더 잘 처리 할 수 ​​있습니다.

예스퍼 - 덴마크

답변

1

제안의 몇 :

확인 파일의 업로드 경로. 나는 파일이 저장되는 위치를

$handle->Process("profil/store"); 

입니다 가정합니다. 파일이 업로드되지 않은 경우에 대비하여 파일 권한을 확인하십시오.

또한 아래 코드가 작동합니까? 나는 틀릴 수도 있지만 바인딩되기 전에 매개 변수를 설정하면 안됩니까? 즉

  $query = 'INSERT INTO `bruger` ' 
        . '(`Brugernavn`, `password`, `profilbillede`, ' 
        . '`navn`, `efternavn`, `alder`) ' 
        . 'VALUES (?, ?, ?, ?, ?, ?)'; 
      if ($stmt = $mysqli->prepare($query)) 
      { 

      $brugernavn = $_POST["brugernavn"]; 
      $password  = $_POST["pass"]; 
      $profilbillede = $pb; 
      $navn   = $_POST["navn"]; 
      $efternavn  = $_POST["efternavn"]; 
      $alder   = $_POST["alder"]; 

      $stmt->bind_param(
       'sssssi', 
       $brugernavn, 
       $password, 
       $profilbillede, 
       $navn, 
       $efternavn, 
       $alder 
      ); 

이 정보가 도움이 되었기를 바랍니다.

+0

당신이 그것을 어떻게 생각하는지 볼 수 없어요, 시도하지만 적응하거나 모방 할 찾을 수 없습니다;) –

+0

당신은 코드를 에뮬레이트하려고 시도 할 수 없다, 그래서 그것은 나는 그것을 더 잘 이해할 수있다 :) –

+0

지금은 작동하고 도움을 주셔서 감사합니다 !!!! 다시 한 번 감사드립니다! –

0

가 귀하의 파일 업로드 필드가 실제로 profilbillede 이름 : 당신이 그것을 사용하는대로 $_FILES['profilbillede']하지 $_FILES['file'] 수 있습니다 의미

     <td><input type="file" name="profilbillede"></td> 
                ^^^^^^^^^^^^^ 

.

+0

$ handle = new 업로드 ($ _ FILES [ 'profilbillede']); 그래서 여기에 표시되어야합니까? –

+0

난 그냥 시도하고 작동하지 않습니다 : ( –