close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

PHP jQuery File Upload

Thread began 8/31/2021 10:30 am by Daniel | Last modified 9/01/2021 9:36 am by Ray Borduin | 168 views | 2 replies |

Daniel

PHP jQuery File Upload

Good Day,
I'm doing a multiple file upload with jQuery.

Here is the code:
1. jqueryFileUpload.php page:
$("#submit-button").click(function() {
var formData = new FormData();
var file = $("#file")[0].files[0];
var fileTwo = $("#fileTwo")[0].files[0];
var fileThree = $("#fileThree")[0].files[0];
formData.append('file', file);
formData.append('fileTwo', fileTwo);
formData.append('fileThree', fileThree);

$.ajax({
url: 'jqueryFileUploadB.php',
type: 'post',
data: formData,
contentType: false,
processData: false,
success: function(data){
alert('Successful jQuery file upload to: ' + data)
}
});
$("#jquery-upload-form")[0].reset();
});

2. jqueryFileUploadB.php page:
require_once("webassist/file_manipulation/helperphp.php");
if (isset($_FILES['file']['name'])) {
$uploadOne = move_uploaded_file($_FILES['file']['tmp_name']);
// WA_UploadResult1 Params Start
$WA_UploadResult1_Params = array();
// WA_UploadResult1_1 Start
$WA_UploadResult1_Params["WA_UploadResult1_1"] = array(
'UploadFolder' => "images/",
'FileName' => "".$_FILES['file']['name']."",
'DefaultFileName' => "",
'ResizeType' => "0",
'ResizeWidth' => "0",
'ResizeHeight' => "0",
'ResizeFillColor' => "" );
// WA_UploadResult1_1 End
// WA_UploadResult1 Params End
WA_DFP_SetupUploadStatusStruct("WA_UploadResult1");
WA_DFP_UploadFiles("WA_UploadResult1", $_FILES['file']['tmp_name'], "2", "[NewFileName]_[Increment]", "false", $WA_UploadResult1_Params);
};

What PHP should change on the 'jqueryFileUploadB.php' page for the file to upload like it normally would if the PHP runs on the same page as the form?

Thank you.

Sign in to reply to this post

Ray BorduinWebAssist

I don't really understand your question. Does it all work now, you just want to change the page that it works on? It looks like you have 3 files uploading, but only 1 is accounted for in the server code. Does the first one work and not the other two?

I need to understand what exactly is and isn't working and what your question is exactly before I can attempt to answer.

Sign in to reply to this post
Did this help? Tips are appreciated...

Daniel

Ray thank you for responding.

In the process since yesterday I managed to get it right.

What I meant with the question was:
Yes I did want the form to function on another page without going to the other page and without like a page refresh when the form submits but I managed to make it operate with jQuery.

Thank you for your help.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...