We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28779
    • 25 Posts
    Hey Dimmy,

    Download works great now, thanks. I’ve just had a look at the code, and I don’t read Dutch, but I think I can figure out the comments. I think it looks like exactly what I need. It looks like you have included some basic server side resizing on the image too! Fantastic! You rock!

    I will try the code now, and let you know how it works out.

    Cheers
    Subd
      • 28779
      • 25 Posts
      That code works for me up to a point. If I comment the condition below, it is putting all of my fields into the database, except for the image filename. There is no image being uploaded and the condition below is never returning true:
      if($fields['image_name']) &&$_FILES['image_name'])


      It is the portion $_FILES[’image_name’] that is always false.

      I have tried with $_FILES[’image’] also... (Question is $_FILES[’image’] a special global variable...?)

      My form looks like this:
      [+validationmessage+]
      <form method="post" action="[~[*id*]~]">
          <input type="hidden" name="formid" value="feedbackForm" />
          
          <p><label accesskey="t" for="title">Title</label>
          <input type="text" name="title" maxlength="60"  /></p>
      
          <p><label accesskey="body" for="body">Body</label>
          <textarea cols="40" rows="10" name="body" eform="Comments:html:1"></textarea></p>
      <p><label accesskey="i" for="image_name">Image</label>
      <input name="image_name" type="file"   />
      </p>
          <p><input type="submit" name="submit" value="Submit"></p>
      </form>
      


      And my snippet call looks like this:
      [[eform2db_image]]
      [!eForm? &formid=`feedbackForm`  &eFormOnBeforeMailSent=`eform2db_image` &tpl=`eFeedBackForm` &report=`eFeedbackReport` &thankyou=`eFeedBackThanks` &noemail=`1` !]
      


      Any ideas what I might be doing wrong?
        • 7455
        • 2,204 Posts
        you have to make sure that the temp settings are ok with your server setting

        everywhere where you have : $_FILES[’image’]; it needs to be $_FILES[’image_name’]

        then also you upload paths /server path needs to be ok

        All the $fields[’naam’] needs to be something that you want the name to be if its the real file name then you need to use $_FILES[’image_name’] instead.

        you could try to print_r($_FILES) to see all the values in (and to see if any exist)

        Dimmy
          follow me on twitter: @dimmy01
          • 28779
          • 25 Posts
          I change all my $_FILES[’image’] to $_FILES[’image_name’]

          I am getting an empty array when I print_r($_FILES), at the start of the eform2db_image snippet. It looks like I am not calling eform right, but I can’t see where the problem is.

            • 28779
            • 25 Posts
            Actually, something weird is happening, its putting the first letter of the original filename and inserting that into the database. Here’s 1 record:

            0 asdsad sdfsdf sdfdsf m 2008-04-26 17:08:02

            where ’m’ is the image_name column of the database
              • 28779
              • 25 Posts
              OK, stupid mistake, the form needed to specify multipart data

              <form method="post" enctype="multipart/form-data">
              
                • 28779
                • 25 Posts
                Ok, now I’m getting this:

                This first line is the results of dumping the $_FILES variable.
                I’m not sure why the extra .jpg is being added onto the end. The original filename is image01.jpg. I’m also not sure why its not appearing in the tmp folder...

                Any ideas?

                Array ( [image_name] => Array ( [name] => image01.jpg [type] => image/jpeg [tmp_name] => C:\xampp\tmp\php598.tmp [error] => 0 [size] => 47442 ) )
                « MODx Parse Error »
                MODx encountered the following error while attempting to parse the requested resource:
                « PHP Parse Error »
                 
                PHP error debug
                  Error: 	fopen(C:\xampp\htdocs\modx\assets\fotowedstijd\image01.jpg.jpg) [function.fopen]: failed to open stream: No such file or directory	 
                  Error type/ Nr.: 	Warning - 2	 
                  File: 	C:\xampp\htdocs\modx\assets\snippets\fotowedstrijd\snapshot.class.php	 
                  Line: 	136	 
                  Line 136 source: 	if (!$handle = fopen($destination, 'w')) { 	 
                 
                Parser timing
                  MySQL: 	0.0167 s	(4 Requests)
                  PHP: 	0.8373 s	 
                  Total: 	0.8540 s
                
                  • 7455
                  • 2,204 Posts
                  the extra comes from the places whe I used this:
                  /assets/fotowedstijd/".$fields[’naam’].".jpg";

                  you probebly changed that to /assets/fotowedstijd/".$_FILES[’name’].".jpg";
                  if you did that than lose the .".jpg" part
                  because the $_FILES[’name’] already has a .jpg extention. ([name] => image01.jpg)

                  Dimmy

                    follow me on twitter: @dimmy01
                    • 28779
                    • 25 Posts
                    I got it working! My paths were all messed up, but once I fixed them it worked a treat. Thanks Dimmy for all your help. I buy you beer!
                      • 7455
                      • 2,204 Posts
                      Good to hear that you got it working
                        follow me on twitter: @dimmy01