I am a novice, originally is to learn Java, but just a into the company to make PHP Web page, do not understand Ah, this two days manager let me do an upload compressed file button, can upload, but in the target file but not receive my uploaded files, I copy the code over, I hope the road heroes can give guidance, grateful.
/*
Uploadify
Copyright (c) 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 ';
}
Reply to discussion (solution)
The uploaded file will be stored in the directory that the $targetPath points to
Please verify that the directory is real and has write permission
Ditto!!!
Directory is real, but I first was uploaded to the C-disk, may be the C-disk system can not upload the disk, after I changed to e-disk, can not upload, and the folder's properties are read-only state, not to change, this situation is how to go? Is the reason for the folder properties, or My code is a problem, please take a closer look at me, thank you ah, I have this little button for one weeks.
I changed $targetfolder = '/nrgl/photos ' to $targetfolder = ' e:\\photos '; and $targetpath = $_server[' Document_root ']. $targetFolder changed to $targetpath = $targetFolder; do not know the code to change the right, please advise!
Because $targetfolder = '/nrgl/photos ' is relative to the path, so I put $_server[' document_root ']. Got rid of, don't know right. It should not be a question of whether the directory exists or not, because I can upload photos from the beginning.