php - Upload file. After uploading will be save in the place where i have stated -


i upload docx location "c:\xammp\htdocs\fyp3\uploads/" below codes uploading file. now, after click on upload, cannot find file in given address. not sure error is. in advance:)

if(isset($_files['file']))         {             $file=$_files['file'];               $file_name=$file['name'];             $file_tmp = $file['tmp_name'];             $file_size = $file['size'];             $file_error = $file['error'];              $file_ext = explode('.',$file_name);             $file_ext = strtolower(end($file_ext));              $allowed=array('docx', 'jpg');              if(in_array($file_ext, $allowed))             {                 if($file_error === 0)                 {                     if($file_size <= 2097152)                     {                         $file_name_new = uniqid('', true) . '.' . $file_ext;                         $file_destination = "c:\xammp\htdocs\fyp3\uploads/" . $file_name_new;                          if(move_uploaded_file($file_tmp, $file_destination))                         {                             echo $file_destination;                         }                        }                 }             }           } 

below form code:)

<form action="homepage.php" method="post" enctype="multipart/form-data">         <input type="file" name="file">         <input type="submit" value="upload">       </form> 

first of please check method attribute of , must post , check enc-type attribute, must multipart-form data. if these both things ok, in php code block use print_r($file) if form posted file print properties of file. if every thing fine till point check destination path , directory permission, may dont have permission write file. think "c:\xammp\htdocs\fyp3\uploads/" . $file_name_new; last slash "uploads/" in wrong format. please check it. that's it.


Comments

Popular posts from this blog

gridview - Yii2 DataPorivider $totalSum for a column -

java - Suppress Jboss version details from HTTP error response -

Sass watch command compiles .scss files before full sftp upload -