简体   繁体   中英

Move uploaded file inside a server

I'm trying to move an uploaded file inside my server on my Cpanel hosting. I am using the PHP function move_uploaded_file, but how do I know the exact path of my Server?

I tried using this syntax:

move_uploaded_file($filelocation, http://website.com/thisfolder/filename.txt);

i do know that my file location variable is outputting correctly as I could see that it goes into var/ directory of the server.

I want the path in my filemanager that has the public_html folder.

/ServerName1/ServerName2/public_html/Folder1/thisfolder

How do I place it into the correct directory?

<?php
$uploads_dir = '/uploads';
foreach ($_FILES["pictures"]["error"] as $key => $error) {
    if ($error == UPLOAD_ERR_OK) {
        $tmp_name = $_FILES["pictures"]["tmp_name"][$key];
        $name = $_FILES["pictures"]["name"][$key];
        move_uploaded_file($tmp_name, "$uploads_dir/$name");
    }
}
?>

A sample code of how to upload to a directory. You can find more examples here : http://us1.php.net/move_uploaded_file

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