Uploading files from an html page and a php script

Hi, i was coding a little html page to upload files, but every time i try to upload some files, it reports me these

[code] errorsç
Warning: move_uploaded_file(/pmimage/Asl.docx): failed to open stream: No such file or directory in /storage/h10/343/1491343/public_html/getfile.php on line 21

Warning: move_uploaded_file(): Unable to move ‘/storage/h10/343/1491343/tmp/php2J53z0’ to ‘/pmimage/Asl.docx’ in /storage/h10/343/1491343/public_html/getfile.php on line 21

[/code]
I changed permission for the folder /pmimage so that “Group” and “Others” can write on it. I think that the code is ok, but i’ll post it

[code]

<?php if (!isset($_FILES['userfile']) || !is_uploaded_file($_FILES['userfile']['tmp_name'])) { echo 'No files.'; exit; } $uploaddir = '/pmimage/'; $userfile_tmp = $_FILES['userfile']['tmp_name']; $userfile_name = $_FILES['userfile']['name']; if (move_uploaded_file($userfile_tmp, $uploaddir . $userfile_name)) { echo 'Success.'; }else{ echo 'Not a success!'; } ?>[/code]

What is line 21 of getfile.php?

Sorry, the second if ( if (move_uploaded_file($userfile_tmp, $uploaddir . $userfile_name)) )

Probably it’s a permission problem, but i don’t know how to resolve it on 000webhost

Try this instead:

<?php
if (!isset($_FILES['userfile']) || !is_uploaded_file($_FILES['userfile']['tmp_name'])) {
  echo 'No files.';
  exit;    
}
$uploaddir = '/pmimage/';
$userfile_tmp = $_FILES['userfile']['tmp_name'];
$united = $uploaddir . basename($_FILES['userfile']['name']);
if (move_uploaded_file($userfile_tmp, $united)) {
  echo 'Success.';
}else{
  echo 'Not a success!'; 
}
?>

Same problem in the second if (line 9)

I tried to create a new empty folder (changing the permissions), but nothing

It was a stupid error: the path doesn’t start with /, so it’s ‘pmimage/’. Thank you guys and sorry for this little error