简体   繁体   中英

php file uploading and storing

  1. I want to upload a file on my PHP server. I am currently able to upload it on server using the following code but I don't know how I can store it on the server. How can I store the file in a specific directory?

  2. I also want the users to be able to download the files but only once they log in not before that.

    For example i store the file in directory /myfiles no-one must be able to download it unless he is logged in

    eg someone can download the file if he knows the file location like www.example.com/temp/myfile.txt

    I don't want that - user must not be able to download it unless he is logged in.

  3. I have one page B.php in which there will be the download link. When the user clicks on that link he must be able to download the file. In short, he must get a Save as/Open pop up of browser when he clicks my link. How do I do that?

在此处查看有关move_uploaded_file()的PHP文档: http : //de.php.net/manual/zh/function.move-uploaded-file.php

function UploadData()
{
        $yourpath ="yourfoldername";
    createafolder($yourpath ); // if not present then create it (its custom function)

    $target_path = $yourpath . basename( $_FILES['fileupload']['name']); 

    if(move_uploaded_file($_FILES['fileupload']['tmp_name'], $target_path)) {
               //write if any processing
    }
            else echo "Upload sucessful!";

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM