0

My code:(for append field so taken k)

$num4 = count($_FILES['attach_doc']['name']);

    for($k = 0; $k < $num4; $k++) {

      $fname = pathinfo($_FILES['attach_doc']['name'][$k], PATHINFO_FILENAME); // Returns Filename without extention
      $exn = pathinfo($_FILES['attach_doc']['name'][$k], PATHINFO_EXTENSION); // Returns extention without Filename
      $docs = $fname.'-'.date("dmY").$k.'.'.$exn;

$intd = move_uploaded_file($_FILES["attach_doc"]["tmp_name"][$k], 'uploads/dev_req/attachment/'.$docs);


     $sql4 = mysqli_query($con, "INSERT INTO `erpdev_supporting_document` (`unique_id`, `supporting_doc`, `status`) VALUES ('$uid', '$docs', '1')");

     $msg = "<p style='color:#1578a5;'><strong>Request data has been added successfully</strong></p>";
    }

showing error:

Warning: move_uploaded_file(): Unable to move 'G:\xampp\tmp\php85A7.tmp' to 'uploads/dev_req/attachment/blog33_10_02_2020-230420200.docx' in G:\xampp\htdocs\erp\basic\erp_dev\panel\dev_request.php on line 56

Jay Blanchard
  • 34,243
  • 16
  • 77
  • 119
smita
  • 1
  • Does the web application have permission to write to that directory? Have you checked your error logs? – Jay Blanchard Apr 23 '20 at 12:55
  • Does the folder exist? Have you tried using the full path? – brombeer Apr 23 '20 at 12:56
  • 1
    ***Pro tip:*** [Do not act needy and do not say your requirement is urgent](https://meta.stackoverflow.com/q/326569/1011527) or ask for replies ASAP. The folks answering questions are volunteers with busy lives, just like yours. – Jay Blanchard Apr 23 '20 at 12:56
  • [Little Bobby](http://bobby-tables.com/) says ***[your script is at risk for SQL Injection Attacks.](http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php)*** Learn about [prepared](http://en.wikipedia.org/wiki/Prepared_statement) statements for [MySQLi](http://php.net/manual/en/mysqli.quickstart.prepared-statements.php). Even [escaping the string](http://stackoverflow.com/questions/5741187/sql-injection-that-gets-around-mysql-real-escape-string) is not safe! – Jay Blanchard Apr 23 '20 at 12:57

0 Answers0