<div>Hi All</div>
<div>I am using Drupal 6.26.</div>
<div> </div>
<div>I am trying to upload a file. One user can upload only one file.</div>
<div>After a while, if user wants to upload another file, I need to delete the first file and upload the second file.</div>
<div>To delete the first file, I do a query to get the first file name, deletes first file and uploads the second file.</div>
<div>After a while, if user wants to upload another file, when I do query to get the second file name (as I want to delete the second file now), I always get the first file name.</div>
<div>So I am not able to delete the second file.</div>
<div> </div>
<div>Probably database cache plays a role here, how can I make sure, my query returns the latest data present in table, query should not pick the data from cache.</div>
<div> </div>
<div>Please refer code below.</div>
<div> </div>
<div> global $user;<br> $FID = -1;<br> <br> $result = db_query("SELECT fid, filepath FROM {resubmt_table} LEFT JOIN {files} USING (fid) WHERE resubmt_table.uid = %d", $user->uid);<br> $obj = db_fetch_object($result);<br>
if($obj)<br> {<br> $FID = $obj->fid;<br> if($obj->filepath)<br> {<br> if(file_exists($obj->filepath))<br> {<br> drupal_set_message("File exists deleting " . $obj->filepath);<br> unlink($obj->filepath);<br>
}<br> else<br> {<br> drupal_set_message("File does not exists, so not able to delete, file = " . $obj->filepath);<br> }<br> }<br> }</div>
<div><br> </div>
<div>Many times, I am not able to delete the file.</div>
<div>Please suggest how can I fix this issue.</div>
<div> </div>
<div>Thanks</div>
<div>Kamal</div>
<div>NECS, Bangalore</div>
<div> </div>
<div> </div>
<div> </div>