Welcome Guest, Not a member yet? Register   Sign In
using iframe

hi to all,

I have a page with have uploading files or images, I used an iframe and javscript to avoid refreshing page and displaying uploaded image instantly. I was used this without using CI framework before. But since last week, I started using CI framework which is great because it has a good documentation, user guide and especially good forum.

My question is how to call my php file as my form action? I tried to put my (ap.php) file under views folder and call as below.

I am thinking to put this file into libraries and load in my controller but I don't know how exactly what to do.

thanks in advance


<form enctype="multipart/form-data" target="framecustomize" id="customize_bcard" name="customize_bcard" action="<?= base_url()?>ap.php" method="post">
  <div class="error">My Personalized Business Card</div>  
  <div style="margin-top: 15px;display: none" id="f1_upload_process">Loading...<br/><img src="images/loader.gif"/></div>
  <div id="f1_upload_form">                
      <div style="margin-top: 5px">Upload Logo with pixel size (Width and Height) shown below: &lt;input type="file" name="customize" id="customize" /&gt;&lt;/div>
  <div style="display:none">                          
    &lt;iframe src="#" name="framecustomize" id="framecustomize" width="0" height="0" align="center"&gt;&lt;/iframe>
  <div><span class="error">100  x 100</span> or <span class="error">250 x 86</span> only</div>
  <div style="margin: 15px 0 15px 0">
    &lt;input name="select" type="submit" class="highlight" id="select" value="Upload Logo" /&gt;      
  <div style="margin: 15px 30px 10px 10px">
      <div style="width: 100px; height: 100px; margin: 20px 0 0 15px; display: inline-block" id="customize_bcard_img"></div>

here is my (ap.php)

include_once ("include/session.php");

$filename = $_FILES['customize']['name'];
$type = $_FILES['customize']['type'];
$size = $_FILES['customize']['size'];

  $result = 0;
  $pathimage = json_encode('error');
//In this case I only want the server to recieve jpg images.
if (($type != "image/pjpeg") && ($type != "image/jpeg") && ($filename != ""))
      $result = 1;
      $pathimage = json_encode('error');
      $realpath = "companylogo/".$filename;
      //Upload file
      if (move_uploaded_file($_FILES['customize']['tmp_name'], $realpath))
           $username = $session->username;
           $sql = "UPDATE ".TBL_USERS." SET backimage = 'gallery/images/card_bg.jpg', personal_logo = '$realpath' WHERE username = '$username'";
           $result = 2;
           $pathimage = json_encode($realpath);

[removed]window.top.window.stopUpload(&lt;?php echo $result; ?&gt;,&lt;?php echo $pathimage; ?&gt;);[removed]

this javascript will display the uploaded image.

Theme © iAndrew 2016 - Forum software by © MyBB