Menu

link to file needs to be "<img src= etc

Help
GregB49
2007-10-16
2013-06-03
  • GregB49

    GregB49 - 2007-10-16

    This is a great form. I amazed at what you can do with it. I use it to upload photos to a NUCLEUSCMS web site, using a CRONJOB. However, the picture appears as

    Attach your Picture here: http://mysite.com/tempFiles/form2484/files/file_3_33390316102007.jpg (original file name: 0709list200.jpg)

    Where and how do I change the code so that the upload displays the phot on the web site, ie using something like
    <img src="http://mysite.com/tempFiles/form2484/files/file_3_33390316102007.jpg">

    Greg

     
    • TNTEverett

      TNTEverett - 2007-10-18

      The current method of storing files was chosen to further enhance the ability to handle multiple connections saving multiple files at the same time and still avoid duplicate file names.  A better solution for you would be to mask what is sent to the user by providing a descriptive hyperlink to the somewhat encrypted filename stored by your form. 
      Without seeing your form code I can not give any specifics on how this change should be made to your form. 

       
      • GregB49

        GregB49 - 2007-10-18

        Thanks tnt,

        Do I assume that you mean the processor.php file? I hope so - it follows. I think that I need to learn more about how this actually works so that I can understand how to amend it, so any advice will be appreciated

        Greg

        <?php

        $where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/"));

        session_start();
        if( ($_SESSION['security_code']==$_POST['security_code']) && (!empty($_POST['security_code'])) ) {
        // File upload handling
        if($_FILES['field_3']['name']!=''){
        $field_3_filename = "file_3_".date("sihdmY").substr($_FILES['field_3']['name'],strlen($_FILES['field_3']['name'])-4);
        if(!move_uploaded_file($_FILES['field_3']['tmp_name'], "./files/".$field_3_filename)){
        die("File " .  $_FILES['field_3']['name'] . " was not uploaded.");
        }
        }

        mail("post@myaddress.com [real address not shown]","phpFormGenerator - Form submission","Form data:

        Your Name: " . $_POST['field_1'] . "
        Your Comments: " . $_POST['field_2'] . "
        Attach your Picture here: ".$where_form_is."files/".$field_3_filename." (original file name: " . $_FILES['field_3']['name'] . ")

        powered by phpFormGenerator.
        ");

        include("confirm.html");
        }
        else {
        echo "Invalid Captcha String.";
        }

        ?>

         
    • GregB49

      GregB49 - 2007-10-18

      PS. The FORM(?) code, for the attachment, from the form.html page is:

      <li class="mainForm" id="fieldBox_3"> <label
      class="formFieldQuestion">Attach your Picture
      here&nbsp;*&nbsp;<a class="info" href="#"><img
      src="imgs/tip_small.png" border="0"><span
      class="infobox">Attach your picture here, no wider than 450
      pixels please</span></a></label><input
      class="mainForm" name="field_3" id="field_3"
      value="" type="file"></li>

       
      • TNTEverett

        TNTEverett - 2007-10-18

        Change this line in the email message area:
        Attach your Picture here: ".$where_form_is."files/".$field_3_filename." (original file name: " . $_FILES['field_3']['name'] . ")

        Change to this:
        Your Picture is here: <a href=".$where_form_is."files/".$field_3_filename."> (original file name: " . $_FILES['field_3']['name'] . ")</a>

        This will create a hyperlink on the original file name. 

         
        • GregB49

          GregB49 - 2007-10-19

          Many thanks for your reply. That piece of code still gives me the same problem. That is: A link is displayed on the web site but not the picture, however you have pointed me in the right direction. I changed the code, to that shown below, and suddenly the picture appears
          --------------
          Your Picture is here: <img src=".$where_form_is."files/".$field_3_filename." />
          (original file name: " . $_FILES['field_3']['name'] . ")

          --------------
          The actual entry on my Nucleus, PostMan plugin, web site now appears like so:
          --------------
          phpFormGenerator - Form submission
          Oct 19, 2007 by admin  | Add comment

          Form data:

          Your Name: tester
          Your Comments: test

          Your Picture is here:

          [and the picture is displayed - excellent!]
          --------------

          My wish list is now to achieve:

          1.  Include the posters email address in the form.html, without it being displayed on the web site.
          2.  Remove the comments like "Your Name:" and "Your Comments:" from appearing on the site
          3.  Include some php that resizes the uploaded picture, on the fly, to a maximun of 450 pixels wide.

          and am inspired to examine php a bit more, to see how to achieve that.

          Thanks again. Greg

           
          • TNTEverett

            TNTEverett - 2007-10-19

            OK, my bad!  I forgot that you said you wanted the picture to appear.  Personnaly I would add the hyperlink as well as displaying the image.  For the most part the syntax is standard HTML with the exception of using PHP variables to get the right stuff to display at the user end. 
            Let me know if you still need assistance. 

             
            • GregB49

              GregB49 - 2007-10-19

              Yes, I must get a grip of the php variables. If I hit a brick wall again, I'll ask - many thanks. If I achieve something worthwhile, I'll post here as it might be a useful enhancement to this very good form. Greg

               

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.