I am developing a web application with a file upload.
I just writted an php code to upload an image.
if(isset($_FILES['equipmentPictureName'])){
$file_tmp =$_FILES['equipmentPictureName']['tmp_name'];
$file_name = $_FILES['equipmentPictureName']['name'];
$uploads_dir = '/pic';
echo "on file upload if";
if(move_uploaded_file($file_tmp,$uploads_dir.$file_name)){
echo "uploaded";
exit();
}else
{
echo "error on upload";
exit();
}
}else{
echo "File Not Present";
exit();
}
When I run this code I can get output like on file upload if error on upload
I give 777 permission to pic folder
What is the issue, Any Idea,,
Form..
<form action="manage-ahri-action.php" method="post" name="equipment" enctype="multipart/form-data" id="multiple_upload_form" >
<div class="col-lg-6 col-sm-6 row" style="margin-bottom: 15px;">
<div class="form-group">
<label for="" class="col-lg-4 col-sm-4" style="text-align: right;">Equipment Picture</label>
<div class="col-lg-8 col-sm-8">
<div class="option-group uploading none">
<span class="file-button btn-primary" style="margin-right: 14px;">Choose File</span>
<input name="equipmentPictureName" type="file" class="form-control form-white"/>
</div>
</div>
</div>
</div>
<div class="file col-lg-12 col-sm-12 col-md-12">
<button type="submit" class="btn btn-primary btn-square" style="margin-top: 20px">Submit</button>
</div>
</form>
Print_R
Array ( [equipmentPictureName] => Array ( [name] => cat-01.jpg [type] => image/jpeg [tmp_name] => /tmp/php96PS5A [error] => 0 [size] => 72413 ) [accreditations] => Array ( [name] => [type] => [tmp_name] => [error] => 4 [size] => 0 ) [Brochures] => Array ( [name] => [type] => [tmp_name] => [error] => 4 [size] => 0 ) )
Thanks
/
between$uploads_dir.$file_name
it would be$uploads_dir."/".$file_name
– Saty$uploads_dir = './pic/';
– Abbas