2014-12-18 4 views
0

안녕하세요 저는 내 학교 프로젝트에서 작업하고 있지만 문제는 영어가 잘 못되어서 설명하기 위해 최선을 다할 것입니다.PHP 경로에서 변수를 사용하는 방법

PHP 스크립트를 사용하여 파일을 업로드하고 있습니다. 모든 정적 경로로 테스트했습니다. $ file_destination = "/ uploads /.$ file_name_new";

으로 변경했지만 으로 변경하면 $ file_destination = "/ uploads/$ gebruiker /.$ file_name_new"; 그것 doenst 일 나는 또한 그것을 시도했다 '/'내가 뭘 잘못하고 있니 ??? !

$file_destination = "uploads/".$gebruiker."/".$file_name_new; 

그리고 디렉토리에 있습니다


<?php 
session_start(); 
require_once('Connections/RemoteServer.php'); 

$gebruiker = $_SESSION['MM_Username']; 

if(isset($_FILES['file'])){ 
    $file= $_FILES['file']; 

    //eigenschappen bestand 

    $file_name = $file['name']; 
    $file_tmp = $file['tmp_name']; 
    $file_size = $file['size']; 
    $file_error = $file['error']; 

    //file extensie 
    $file_ext = explode('.', $file_name); 
    $file_ext = strtolower(end($file_ext)); 

    //"/users".$username."/"; test!!!!! 

    $allowed = array('txt', 'pdf', 'docx'); 

    if(in_array($file_ext, $allowed)) { 
     if($file_error === 0){ 
      if($file_size <= 5000000) { 

       $file_name_new = uniqid('', true) .'.'. $file_ext; 
       $file_destination ="/uploads/$gebruiker/.$file_name_new"; 
       if(move_uploaded_file($file_tmp, $file_destination)){ 


       echo($file_name ." Is met succes Geupload"); 


       } 


      } 
     } 

    } 

} 



?> 

[루트 구조] [1] 마감 tommorow :(

+0

수 있습니다. 파일 이름의 시작 부분에 점이 있기 때문에 서버에 숨겨진 파일이 보입니까? – Eeji

답변

0

당신은 문자열의 외부 변수를 넣어야 할 존재할 수 있습니다.

mkdir("uploads/".$gebruiker); 
$file_destination = "uploads/".$gebruiker."/".$file_name_new; 
+0

당신의 도움을위한 thx하지만 나는 이미이 오류가 발생했습니다 : 경고 : move_uploaded_file (/uploads/Marvin/54935d060d3904.22699500.pdf) : 스트림을 열지 못했습니다 : C : \ xampp \ htdocs \ CSMS_VERSIE2에 그런 파일이나 디렉토리가 없습니다. .0 \ uploadfile.php on line 31 ////하지만 이미지도를 만들었습니다. 마빈 – marrie

+0

아, 그래. 따라서 폴더가 존재하지 않습니다. 1 초, – baao

+0

에 해당 폴더가 없습니다.이 폴더 업로드/마빈을 안에 만들었습니까? – marrie

관련 문제