Hi...i would like to save and edit some excel files located in server using php. The coding below upload the file but when i open the page again...the message 'no file chosen' appears. Please help on this matter...thanks a lot...

error_reporting(E_ALL ^ E_NOTICE);
$conn = mysql_connect("localhost","pqa","");

if(count($_POST)>0) {

mysql_query("UPDATE progress set Attachment2='" . $_POST["Attachment2"] . "',
Attachment21='" . $_POST["Attachment21"] . "' WHERE Progressid='" . $_SESSION["Progressid"] . "'");
$message = "Record Modified Successfully";


$result = mysql_query("SELECT * FROM progress WHERE Progressid='" . $_SESSION["Progressid"] . "'");
$row= mysql_fetch_array($result);
<title>Add New User</title>
<link rel="stylesheet" type="text/css" href="styles.css"/>
<form name="<?php echo $_SERVER['PHP_SELF']?>" method="post" action="">
<div style="width:500px;">
<div class="message"><?php if(isset($message)) { echo $message; } ?></div>
<div align="right" style="padding-bottom:5px;"><a href="list_progress2.php" class="link"><img alt='List' title='List' src='images/list.png' width='15px' height='15px'/> List Progress</a></div>
<ENCTYPE="multipart/form-data">c.i.Preformatted Forms: <input type="file" name="Attachment2" MAXLENGTH=50 ALLOW="text/*" value="<?php echo $row['Attachment2']; ?>"><br>
<ENCTYPE="multipart/form-data">c.ii.School/Department Forms: <input type="file" name="Attachment21" MAXLENGTH=50 ALLOW="text/*" value="<?php echo $row['Attachment21']; ?>"><br>
<input type="hidden" name="Targetid" ><br>
<td colspan="2"><input type="submit" name="submit" value="Submit" class="btnSubmit"></td>

Recommended Answers

All 2 Replies

You need to do this with a csv file.

    //Upload File
51  if (isset($_POST['submit'])) {
52      if (is_uploaded_file($_FILES['filename']['tmp_name'])) {
53          echo "<h1>" . "File ". $_FILES['filename']['name'] ." uploaded successfully." . "</h1>";
54          echo "<h2>Displaying contents:</h2>";
55          readfile($_FILES['filename']['tmp_name']);
56      }
58      //Import uploaded file to Database
59      $handle = fopen($_FILES['filename']['tmp_name'], "r");
61      while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
62          $import="INSERT into tablename(item1,item2,item3,item4,item5) values('$data[0]','$data[1]','$data[2]','$data[3]','$data[4]')";
64          mysql_query($import) or die(mysql_error());
65      }
67      fclose($handle);
69      print "Import done";
71      //view upload form
72  }

Hi...thanks a lot for your fast reply...sorry for not being specific...actually i just want to upload the excel file to server and whenever i want to edit the file, i just open the page and click on the file to edit it...currently there is no need to import uploaded file to database...please advise,thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.