Here is my javascript code.

function multyTypeUploadAttachments(file,classId,splAttrId){

    var campaignID = $('#wk_custCampID').val();
    if(campaignID == ""){
        var campaignID = $('#wk_edit_camp_ID').val();
    var fileName = $('#'\\fakepath\\/i, '');//form_skuAttachment
    var lastChar =[ -1];
    var upload_data = new FormData($('#wk_multy_form_AttrOptionAttachment'+classId+"-"+splAttrId+"-"+lastChar)[0]);

        url: BASEPATH + 'c_workOrder/uploadSKUAttachments/''/'+campaignID,
        type: 'POST',
        data: upload_data,
        mimeType: "multipart/form-data",
        contentType: false,
        cache: false,
        processData: false,
        success: function (res) {


            toastr.success('Upload success');

        error: function (res) {

and here is php code

function uploadSKUAttachments($file,$campaignID){  
        $ext = substr(strrchr(basename($_FILES[$file]["name"]), '.'), 0);
        $fileName = basename($_FILES["$file"]["name"]);
        $name = basename($fileName,$ext);
        $createdTime = time();
        $target_dir = "./uploads/attachments/";
        $target_file = $target_dir .$campaignID."_".$name."_".$createdTime.$ext;
        $errorFlag = 1;
        $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
        $fullFineName= $name."_".$createdTime.$ext;

        if ($errorFlag == 1) {
                echo true;
            }else if (move_uploaded_file($_FILES["$file"]["tmp_name"], $target_file)) {
                echo $fullFineName;
            } else {
                echo "Sorry, there was an error uploading your file";

And the error I get is as follows:

    Severity: Notice

Message: Undefined index: wk_multy_AttachmentDiv-6-10

Filename: controllers/C_workOrder.php

Line Number: 83

Sorry, there was an error uploading your file

Please upload the file C_workOrder.php

It says the error is on line 83, but the PHP code you are showing us only has 21 lines, so we can't investigate line 83 for you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.