从ajax表单保存上传的文件

从ajax表单保存上传的文件

问题描述:

Its been a long time since i used php and i need some help regarding this basic function.

{
        $msg .= " File Name: " . $_FILES['fileToUpload']['name'] . ", ";
        $msg .= " File Size: " . @filesize($_FILES['fileToUpload']['tmp_name']);

        @unlink($_FILES['fileToUpload']);       
}

Suppose i have a file in the $_FILES['fileToUpload'], how do i create an upload dir if it does not exist, and save the file there?

Thanks!

自从我使用php以来我已经很长时间了,我需要一些关于这个基本功能的帮助。 p> \ n

  {
 $ msg。=“文件名:”。  $ _FILES ['fileToUpload'] ['name']。  “,”; 
 $ msg。=“文件大小:”。  @filesize($ _ FILES ['fileToUpload'] ['tmp_name']); 
 
 @unlink($ _ FILES ['fileToUpload']);  
} 
  code>  pre> 
 
 

假设我在 $ _ FILES ['fileToUpload'] code>中有一个文件,如何创建上传目录if if 它不存在,并将文件保存在那里? p>

谢谢! p> div>

use is_dir() to check if the directory exitst http://us.php.net/manual/en/function.is-dir.php

then use mkdir() if it doesn't exist http://us.php.net/manual/en/function.mkdir.php