I am using this answer, where they use:
move_uploaded_file($_FILES['file']['tmp_name'], 'uploads/' . $_FILES['file']['name']);
which works like a charm, if I create an 'uploads' directory inside the 'php' directory that executes this code.
If I try to do this:
move_uploaded_file($_FILES['file']['tmp_name'], '../img/' . $_FILES['file']['name']);
I am getting this warning:
What am I missing here? I tried with absolute path too!
Directory tree:
scouter
-img
-php
-uplodas
-upload.php
'img' directory seems to have the needed permission options.
EDIT_0:
If I place the file in uploads
dir and then use rename()
it will place the file in img
dir...Can't get what is happening!
EDIT_1:
HTML:
<input id="input_pic" type='file' name='userFile'/>
<div>
<img class="profile_pic" src="img/newname.jpg" alt="player_img" />
</div>
JS:
var file_data = $('#input_pic').prop('files')[0];
var form_data = new FormData();
form_data.append('file', file_data);
alert(form_data);
$.ajax({
url: 'php/upload.php',
dataType: 'text',
cache: false,
contentType: false,
processData: false,
data: form_data,
type: 'post',
success: function(php_script_response){
alert(php_script_response);
}
});
EDIT_2:
The server response, from the answer of swidmann: