We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19439
    • 1 Posts
    Firstpost - enjoy modx hate old docs waiting for revolution sigh...

    So I am wet behind the ears with PHP though I understand enough to make basic things works and know my around but still learning.

    Here is the issue.

    So I have a front end user form with basic input text fields etc and these output fin.

    Issue Time YES!!!I also need it to be able to upload images as well which it can e.g longblob but as we all
    know saving images to a db is good way to get a nasty bill.

    processing the data but I looked high and low for a file upload

    
    <?php
    function formtodatabase( &$fields )
    	{
    		global $modx;
    		$dbTable = array();
    		$dbTable[location] = $fields[location];
    		$dbTable[itemname] = $fields[itemname];
    		$dbTable[price] = $fields[price];
    		$dbTable[disc] = $fields[disc];
    
                    //Nightmares
    		$dbTable[saleimg_1] = $fields[saleimg_1];
    		$dbTable[saleimg_2] = $fields[saleimg_2];
    		$dbTable[saleimg_3] = $fields[saleimg_3];
    
                    /*Code here?
                    Please Mr.PHP send my paths to the db
                    and sir...store the images in a folder
                    
                    Mr.php don't ask me google and get 100 hundred forums of nonsense
                    I know you asked for mysql&php but asp seemed like a good bet too!!!
                    */
    
                    
                   
    		// Run the db insert query
    		$dbQuery = $modx->db->insert($dbTable, 'forsale' );
    		return true;
    	}
    ?>
    


    Or is there some sick joke by eform I have yet to be aware of?

    I looked through tutorial hell but they are are so 1 minded and non-specific not to mention the fact that Eform is in this code gangbang, plus modx functions I might have missed.

    So how the hell do I write a /path to the db and upload the image to a folder? I have been tearing through docs & API to no avail even reading through other snippets for a clue.

    Any help would do wonders and thank you.

    -Mike
      Babies are like poems; they are beautiful to their creator, but to other people they are silly and they are irritating.
      • 21702
      • 10 Posts
      Hello Mike-ssm,

      If it could help, for my own project, i used File Uploadhttp://modxcms.com/extras/package/149, which is really great...

      I had problems too when i tryied to use uploads directly in eform. the wiki is very light on this.

      Then i used eform to insert texts or checkboxs in DB and put just after in the chunk the call of snippet FileUpload and insert in a different table (with a joint).

      Hope that can help you.
        • 21872
        • 95 Posts
        noexus, would you mind explaining for a total beginner the steps required to save a copy of a file that is sent via eform as an attachment? My problem is similar to the OPs, but simpler, I think. I just don’t understand the ’file to folder’ part and
        Then i used eform to insert texts or checkboxs in DB and put just after in the chunk the call of snippet FileUpload and insert in a different table (with a joint).
        is opaque to me.

        Thank you!