Upload compressed files and unzip the problem

Source: Internet
Author: User
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.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.