Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

Edit a post with a image view/delete function

Asked Modified Viewed 1,947 times
C
cis5448
C
  • Junior Member, joined since
  • Contributed 18 posts on the community forums.
  • Started 6 threads in the forums
  • Started this discussions
asked
Junior Member

I have looked into the codes in some files about viewing a uploaded image with a delete function, but something I have missed it because when i updated the post the image disappears. What is wrong with my code???

if (isset($_POST['opret_opdater'])) {
    // This is the question how to validate in Php-Fusion 9

         if (!empty($_FILES['piktogram']) && is_uploaded_file($_FILES['piktogram']['tmp_name'])) {
               $upload = form_sanitizer($_FILES['piktogram'], "", "piktogram");
               if (empty($upload['error'])) {
                $piktogram = $upload['image_name'];
               
               
               
                   addNotice("success", "Piktogram <strong>".$piktogram."</strong> uploadet");
                  // redirect(FUSION_SELF);
               }
               $piktogram = form_sanitizer($_FILES['piktogram']['tmp_name'], "", "piktogram");
            } elseif ($data["id"] >0) {
                if (isset($_POST['del_image'])) {
                  // album_id
                  $result = dbquery("SELECT piktogram FROM ".EVO_AKTIVITET." WHERE id='".$data['id']."'");
                  if (dbrows($result) > 0) {
                     $pData = dbarray($result);
                     if ($pData['piktogram'] && file_exists(BASEDIR."billeder/piktogram/".$pData['piktogram'])) {
                        unlink(BASEDIR."billeder/piktogram/".$pData['piktogram']);
                     }
                     $piktogram = "";
                  }                     
               } else {
                  $piktogram = form_sanitizer($_POST['piktogram'], "", "piktogram");
               }
         } else {
               // because we require the photo image must be uploaded.
               $defender->stop();
               $defender->setInputError("piktogram");
               addNotice("danger", $locale['photo_0014']);
            }
           
             

           

    $data = array(

        "id" => form_sanitizer($_POST['id'], "", "id"),
        "navn" => form_sanitizer($_POST['navn'], "", "navn"),
        "piktogram" => $piktogram,
        "kategori" => isset($_POST['kategori']) ? 1 : 0,
        "menu" => isset($_POST['menu']) ? 1 : 0,
        "kontakt" => isset($_POST['kontakt']) ? 1 : 0

//print_p($data);// if validation not needed, just do like this fastest result
);

    // Use this to stop Insertion/Update to push $data downwards without refresh to see errors on input
    if (\defender::safe()) {
       if ($edit == true) {
           dbquery_insert(EVO_AKTIVITET, $data, "update");
            addNotice("success", "Aktivitet opdateret");
       } else {
       
           dbquery_insert(EVO_AKTIVITET, $data, "save");
           addNotice("success", "Aktivitet oprettet");
       }
     
       redirect("aktiviteter.php");
        //redirect(FUSION_REQUEST); // Please refresh the page to reload page for new token for the form & security reason
    }
0 replies
There are no post found.

Labels

None yet

Statistics

  • Views 0 views
  • Posts 0 posts
  • Votes 0 votes
  • Topic users 1 member

1 participant

C
C
  • Junior Member, joined since
  • Contributed 18 posts on the community forums.
  • Started 6 threads in the forums
  • Started this discussions

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet