• Resolved Mark Parnell

    (@markparnell)


    Hi,

    We are working on a multisite with NS Cloner, including various custom fields on the clone form that we use to help set up the new site. Where we are stuck is that we need to include a file upload field in order to upload an image, however since the clone form is submitted via AJAX we’re unable to work out how to get hold of the file to process it.

    I noticed that the form includes enctype="multipart/form-data" so presumably you’ve taken file uploads into consideration, however we haven’t managed to get that working. Can you point me in the right direction?

    I tried looking at the documentation, but couldn’t see anything that relates to file uploads.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Never Settle

    (@neversettle)

    Hey there @markparnel,

    Thanks for your question ?? There are certain hooks available in the plugin, but I would like to know more on what the file upload field would be used for. For example, there is the hook ns_cloner_process_finish that is called once the clone process is finished that can be used to move the custom file upload and set it up in the destination site.

    Thread Starter Mark Parnell

    (@markparnell)

    Thanks for the quick response. Yes, we are hooking into ns_cloner_process_finish to handle our custom fields and have everything working for other fields – we just can’t work out how to access the file upload, as ns_cloner_request() only seems to look at $_GET and $_POST, not $_FILES. The only thing the POST data seems to have for the file is a dummy path (something along the lines of C:\\\fakepath\\\filename.png).

    Ultimately what we are trying to do is to add the image to the media library for the new site and then store it as the value for a theme option. I’m confident that if we can just manage to access the file details in the first place the rest of it should be smooth sailing.

    Plugin Author Never Settle

    (@neversettle)

    Hey Mark,

    Thanks for the response. I agree this first has to be managed differently with ajax before the values become accessible in the backend.
    Another workaround could be to use custom ajax on the form to upload the file, before the cloning process start. This would just be a hidden field to store the file path or attachment id, which can then be accessed in the backend. The flow would be :

    – File upload field is displayed on cloning page
    – File is uploaded via ajax on that field and saved as a hidden field
    – Once cloning process is initiated, the hidden field is then parsed in the backend and set in the media library of the new site as an option in the theme option.

    Please let me know what you think ??

    Warm Regards

    Thread Starter Mark Parnell

    (@markparnell)

    Thanks for that. I was hoping the plugin already had a mechanism in place to handle file uploads, but it sounds like we’ll have to do that ourselves. Appreciate your help.

    Plugin Author Never Settle

    (@neversettle)

    Most welcome @markparnell and thank you for bringing this up ?? We will see how easy it is to implement this in later versions. Your feedback is highly appreciated.

    Thread Starter Mark Parnell

    (@markparnell)

    Thanks again. We got it working, though native support in the plugin for file uploads would be fantastic.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘File upload field in clone form’ is closed to new replies.