Jump to content

son.of.the.morning

Members
  • Posts

    292
  • Joined

  • Last visited

    Never

Posts posted by son.of.the.morning

  1. Right i have made a new php file to delete the image but it keeps coming up 'Warning: unlink() [function.unlink]: http does not allow unlinking in /home/a2820511/public_html/testing/image-deleted.php on line 9'

    This is how i have done it....

     

    Table file

      <?php
    while($rows=mysql_fetch_array($result)){ // Start looping table row 
    ?>
      <tr>
        <td class="some-shit"><? echo $rows['id']; ?></td>
        <td class="some-shit"><a href="<? echo $rows['name']; ?>"><? echo $rows['name']; ?></a><br /></td>
        <td align="center" ><? echo $rows['type']; ?></td>
        <td align="center" ><? echo $rows['size']; ?></td>
        <td align="center" ><a href="image-deleted.php?id=<? echo $rows['name'] ?>"><img src="LAS/images/icons/admin/hds/delete.jpg" alt="" width="19" height="19" border="0" /></a></td>
      </tr>
      <?php
    // Exit looping and close connection 
    }
    mysql_close();
    ?>

     

    Delete image file

    <?php 
    $imageDir=$_GET["id"];
    unlink($imageDir);
    ?>
    <script language="text/javascript">
    window.location ="delete-image.php";
    </script>

  2. This part even...[

    function upload_is_valid($upload, $valid_mime, $valid_ext) {    if($upload['error'] != UPLOAD_ERR_OK)        return false;      $finfo = finfo_open(FILEINFO_MIME_TYPE); // Note: PHP 5.3.x    if(!in_array(finfo_file($finfo, $upload['tmp_name']), (array) $valid_mime))        return false;        if(!in_array(pathinfo($upload['tmp_name'], PATHINFO_EXTENSION), (array) $valid_ext))        return false;         return true;}function upload_exists($upload, $directory) {    $filename = pathinfo($upload['tmp_name'], PATHINFO_FILENAME);    return file_exists(rtrim($directory, '\/') . DIRECTORY_SEPARATOR . $filename);}function upload_store($upload, $directory) {    $upload = upload_create($upload);    $filename = pathinfo($upload['tmp_name'], PATHINFO_FILENAME);    return move_uploaded_file(rtrim($directory, '\/') . DIRECTORY_SEPARATOR . $filename);}function upload_create($upload) {    // re-create the image    return $upload;

  3. I was actualy refering to...

    function upload_is_valid($upload, $valid_mime, $valid_ext) {    if($upload['error'] != UPLOAD_ERR_OK)        return false;      $finfo = finfo_open(FILEINFO_MIME_TYPE); // Note: PHP 5.3.x    if(!in_array(finfo_file($finfo, $upload['tmp_name']), (array) $valid_mime))        return false;        if(!in_array(pathinfo($upload['tmp_name'], PATHINFO_EXTENSION), (array) $valid_ext))        return false;         return true;}function upload_exists($upload, $directory) {    $filename = pathinfo($upload['tmp_name'], PATHINFO_FILENAME);    return file_exists(rtrim($directory, '\/') . DIRECTORY_SEPARATOR . $filename);}function upload_store($upload, $directory) {    $upload = upload_create($upload);    $filename = pathinfo($upload['tmp_name'], PATHINFO_FILENAME);    return move_uploaded_file(rtrim($directory, '\/') . DIRECTORY_SEPARATOR . $filename);}function upload_create($upload) {    // re-create the image    return $upload;}

  4. I would like to have more of a understanding of this upload file script if any one would like to be a pal and explain whats going on step by step, thats if it's not to much to ask of course :P.

     

    <?php
                    /* checking the file extension*/
                    if ((($_FILES["file"]["type"] == "image/gif")
                    || ($_FILES["file"]["type"] == "image/jpeg")
                    || ($_FILES["file"]["type"] == "image/png")))
    {
                    /* this code will be executed if the file extension matches they above (gif,jpeg,png)*\
      		if ($_FILES["file"]["error"] > 0) /*if more than 0 errors occur the following code will be executed*/ 
                                        {
                                          /* return code (string), $_FILES...(file var)*/
                                              echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
       				 }
      else  {
                       /*listing file details, name, file type, file size*/
                      echo "Upload: " . $_FILES["file"]["name"] . "<br />";
                      echo "Type: " . $_FILES["file"]["type"] . "<br />";
                      echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
                      /*temp file location*/
                      echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
                      if (file_exists("upload/" . $_FILES["file"]["name"]))
                                    {
                                           /* if there is a file already existing  with the same name as the current file in a procedure then the following code will be executed*/
                                           echo $_FILES["file"]["name"] . " already exists. ";
                             }
      else    {
                      /*moving the successfully uploaded file to the a designated location, in this case upload/.*/
                      move_uploaded_file($_FILES["file"]["tmp_name"],
                      "upload/" . $_FILES["file"]["name"]);
                      echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
                 }
           }
      }
    else   {
              /*this section refers from the first if statement, if the file extension didn’t match the files listed at the beginning of this script then the following code will be executed.*/
                 echo "Invalid file extention”
    }
    ?>
    
    
    
    

×
×
  • 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.