views:

88

answers:

2
  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

    e.g. 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?

+1  A: 

Check the PHP documentation about move_uploaded_file() here: http://de.php.net/manual/en/function.move-uploaded-file.php

powtac
A: 
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!";

}
santosh