/*
uploadify
copyright (c) 2012 reactive apps, ronnie garcia
released under the mit license
*/
$targetfolder = '/nrgl/photos'; // relative to the root
$uuid=$_get['uuid'];
//$verifytoken = md5('unique_salt' . $_post['timestamp']);
//if (!empty($_files) && $_post['token'] == $verifytoken) {
$rand=rand(0,999999999);
//if (!empty($_files) && $_post['token'] == $verifytoken) {
$tempfile = $_files['filedata']['tmp_name'];
$targetpath = $_server['document_root'] . $targetfolder;
$targetfile =rtrim($targetpath,'/') . '/'.$rand.'.' .substr($_files['filedata']['name'],-3,3);
// validate the file type
$filetypes = array('zip','rar','doc'); // file extensions
$fileparts = pathinfo($_files['filedata']['name']);
if (in_array($fileparts['extension'],$filetypes)) {
move_uploaded_file($tempfile,$targetfile);
echo $targetfile;
} else {
echo '1';
}
回复讨论(解决方案) 上传后的文件将存放于 $targetpath 指向的目录中
请确认该目录真实存在,并有写权限
同上!!!
目录是真实存在的,可是我一开始是上传到c盘的,可能c盘是系统盘不能上传上去,之后我改到e盘,可还是上传不上去,并且文件夹的属性是只读状态,改不掉,这种情况是怎么回事呢?是文件夹属性的原因,还是我的代码有问题,请大牛们仔细帮我看下吧,非常感谢啊,我搞这个小按钮已经一个星期了。
我把$targetfolder = '/nrgl/photos'改成$targetfolder = 'e:\\photos';并且把$targetpath = $_server['document_root'] . $targetfolder改成$targetpath = $targetfolder;不知道代码改的对不对,恳请指点!
因为$targetfolder = '/nrgl/photos'是相对路径,所以我把$_server['document_root'] .去掉了,不知道对不对。 应该不是目录是否存在的问题和权限的问题吧,因为我一开始上传照片都能上传进去。