0

my site is hosted in 000webhost , i already made a directory called "Uploaded CVs" in the file manager, but i get this error :

Warning: move_uploaded_file() [function.move-uploaded-file]: open_basedir restriction in effect

php code:

<?php 
$file_result = "";

if ($_FILES["file"]["error"] >0)
{
    $file_result .="File did not upload! Try again!";
    $file_result .="Error occured: " . $_FILES["file"]["error"] . "<br>";
    }else{

    $file_result.=
    "Upload: " . $_FILES["file"]["name"] . "<br>" .
    "Type: " . $_FILES["file"]["type"] . "<br>" .
    "Size: " . ($_FILES["file"]["size"] / 1024 ). " Kb<br>" .
    "Temp file: " . $_FILES["file"]["tmp_name"] . "<br>";

    move_uploaded_file($_FILES["file"]["tmp_name"],
    $_SERVER['DOCUMENT_ROOT'] . "/Uploaded CVs/" . $_FILES["file"]["name"]);

    $file_result .= "CV Uploaded Successfully!";


}
?>

any idea whats the correct path? Thanks.

Nytzruze
  • 7
  • 2

1 Answers1

0

For this example the folder is in the same path that the file.

<?php 
$file_result = "";

if ($_FILES["file"]["error"] >0)
{
    $file_result .="File did not upload! Try again!";
    $file_result .="Error occured: " . $_FILES["file"]["error"] . "<br>";
    }else{

    $file_result.=
    "Upload: " . $_FILES["file"]["name"] . "<br>" .
    "Type: " . $_FILES["file"]["type"] . "<br>" .
    "Size: " . ($_FILES["file"]["size"] / 1024 ). " Kb<br>" .
    "Temp file: " . $_FILES["file"]["tmp_name"] . "<br>";

    if (move_uploaded_file($_FILES["file"]["tmp_name"], "Uploaded CVs/".$_FILES["file"]["name"])) {
       $file_result .= "CV Uploaded Successfully!";
    } else {
       $file_result .= "Error trying to uploas the file";
    }    
}
?>

Take a look to this question

Community
  • 1
  • 1
JuanSedano
  • 1,025
  • 8
  • 14
  • I tried your code, now im getting these errors :.. Warning: move_uploaded_file(Uploaded CVs/ERQstns.docx) [function.move-uploaded-file]: failed to open stream: No such file or directory........... Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpiIQCFh' to 'Uploaded CVs/ERQstns.docx' – Nytzruze Dec 07 '14 at 05:54
  • Do you have the folder named 'Uploaded CVs' in the same path than the file? – JuanSedano Dec 07 '14 at 05:56
  • No, the upload.php file is in public_html and Uploaded CVs is another directry – Nytzruze Dec 07 '14 at 05:58
  • Where do you have it? – JuanSedano Dec 07 '14 at 05:59
  • uploaded cvs is a new directory i made, its in the root directory as the public_html...should i make the 'uploaded cvs' in public_html directory? – Nytzruze Dec 07 '14 at 06:04
  • Yes, you need to create it in the public_html to have access to it. – JuanSedano Dec 07 '14 at 06:07