Jump to content

HTML onclick action to move files


hect1c_newbie

Recommended Posts

Hi, I am new to creating and setting up websites so please. I have very limited knowledge in how websites utilise html, javascript, jquery and/or php together. However I do have some experience developing independent scripts in PHP.  Currently I am working on a project that has the full LAMP stack setup.

 

The webpage I am stuck on is file review and export page.  I have a button with onclick option where I would like the user(once happy) to click go and files move from the web root location to an outbound folder outside of web root on the same server.  These files are first placed in a folder inside the web root on button previously pressed which downloads a set of files from tables setup in mysql.

 

Firstly I assuming this is common workflow and what I am trying to do makes practical sense.

 

My questions are as follows:

 

How can I direct the onclick button to perform the move of files?

What is the best method to do this PHP, Javascript, Jquery?

 

 

Thank you.

Cheers

Chris

 

 

 

Link to comment
Share on other sites

When you say "on click" that typically means using the onClick event in JavaScript. But, based on your explanation, it could just as easily be accomplished with a normal HTML form. But, those are just two methods to initiate the action (i.e. make a call to the server). So, you can either use a traditional HTML form or use an onClick event to make an AJAX call. I would suggest starting with an HTML form to get a working solution, then you can add an onClick event to initiate if you need to perform it without a page refresh.

 

I assume you would have a form with all the relevant files listed and perhaps checkboxes to indicate which files to be moved. You would submit that form to the processing page (PHP) which would take the form data with the list of files and perform a move operation on them. However, allowing user input to be used to perform low level file operations can be risky. You will need to ensure that all input is validated and ensure no malicious references are sent from the user.

 

That is a very high level generalization. If you want more specific help, you will need to provide the specific part that you are stuck on.

Link to comment
Share on other sites

  • 1 month later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.