Jump to content

deleting files


simun

Recommended Posts

i cant find out why i cant delete files from my server, here is my script, please take a look

 

<div id="content">
    <div>
        <h1>Dokumenti</h1>
        </div>
        <div style="padding:10px;">
<?php
$myUpload = new ruverUpload();
$myUpload->uploadFile();
?>

<?

      $dir = new DirectoryIterator( "../../static/dokumenti/" . $_GET['id']  ) ;
      foreach($dir as $file )
      {
        if(!$file->isDot() && !$file->isDir() && preg_match("/.pdf$/",$file->getFilename())) {
?>
	<a href="<? echo "http://rivieradekor.hr/static/dokumenti/" . $_GET['id'] . "/" . $file->getFilename();?>"><? echo $file->getFilename();?></a>
        <? echo '<input type="button" value="Delete" onClick="'.unlink($file->getFilename()).'">' ?>
        <br>
<?
        }
      }
?>
</div>
</div>

Link to comment
Share on other sites

PHP is a server side language -- once the data has been sent from the server to the user, it can do no more. If you want to have a button to delete a file, you need to make another request to the server. If you want to do this without the entire page reloading, you can do so with AJAX. I suggest you look for some beginner tutorials on that.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.