"Uncaught Unknown file id in table image" with second file

"Uncaught Unknown file id in table image" with second file

elherztelherzt Posts: 14Questions: 3Answers: 0
edited March 2020 in General

Hi I am having issues with view the save images.

I have table Doctor_Configs that has 4 images fileds (logo1, logo2, logo3, logo4) related to image table, I can save images with the editor, but when I try to get info I get this error: "Uncaught Unknown file id 18 in table image", id 18 exists I can see it on db.

On table Doctor_Configs in field logo1 I have saved 17, on table user_config in field logo2 I have saved 18, I only have error on id 18 but both exists. id 17 is returned well.

I'm using c#, this my code:

DtResponse response = new Editor(db, "Doctor_Configs", "id")
                    .Model<DoctorConfigModel>("Doctor_Configs")
                    .Model<UserModel>("Users")
                    .Field(new Field("Doctor_Configs.logo1")
                        .SetFormatter(Format.IfEmpty(null))
                        .Upload(
                           new Upload(request.PhysicalApplicationPath + @"uploads\__ID____EXTN__")
                                .Db("image", "id", new Dictionary<string, object>
                                {
                                    {"fileName", Upload.DbType.FileName},
                                    {"webPath", Upload.DbType.WebPath},
                                    {"systemPath", Upload.DbType.SystemPath},
                                })
                                .Validator(Validation.FileSize(500000, "Max file size is 500K."))
                                .Validator(Validation.FileExtensions(new[] { "jpg", "png", "gif" }, "Please upload an image."))
                                )
                    )
                    .Field(new Field("Doctor_Configs.logo2")
                        .SetFormatter(Format.IfEmpty(null))
                        .Upload(
                           new Upload(request.PhysicalApplicationPath + @"uploads\__ID____EXTN__")
                                .Db("image", "id", new Dictionary<string, object>
                                {
                                    {"fileName", Upload.DbType.FileName},
                                    {"webPath", Upload.DbType.WebPath},
                                    {"systemPath", Upload.DbType.SystemPath},
                                })
                                .Validator(Validation.FileSize(500000, "Max file size is 500K."))
                                .Validator(Validation.FileExtensions(new[] { "jpg", "png", "gif" }, "Please upload an image."))
                                )
                    )
                    .Field(new Field("Doctor_Configs.logo3")
                        .SetFormatter(Format.IfEmpty(null))
                        .Upload(
                           new Upload(request.PhysicalApplicationPath + @"uploads\__ID____EXTN__")
                                .Db("image", "id", new Dictionary<string, object>
                                {
                                    {"fileName", Upload.DbType.FileName},
                                    {"webPath", Upload.DbType.WebPath},
                                    {"systemPath", Upload.DbType.SystemPath},
                                })
                                .Validator(Validation.FileSize(500000, "Max file size is 500K."))
                                .Validator(Validation.FileExtensions(new[] { "jpg", "png", "gif" }, "Please upload an image."))
                                )
                    )
                    .Field(new Field("Doctor_Configs.logo4")
                        .SetFormatter(Format.IfEmpty(null))
                        .Upload(
                           new Upload(request.PhysicalApplicationPath + @"uploads\__ID____EXTN__")
                                .Db("image", "id", new Dictionary<string, object>
                                {
                                    {"fileName", Upload.DbType.FileName},
                                    {"webPath", Upload.DbType.WebPath},
                                    {"systemPath", Upload.DbType.SystemPath},
                                })
                                .Validator(Validation.FileSize(500000, "Max file size is 500K."))
                                .Validator(Validation.FileExtensions(new[] { "jpg", "png", "gif" }, "Please upload an image."))
                                )
                    )
                    .LeftJoin("Users", "Users.doctor_id", "=", "Doctor_Configs.id")
                    .Where("Users.uId", user.uId, "=")
                    .Debug(true)
                    .Process(request)
                    .Data();

Answers

  • elherztelherzt Posts: 14Questions: 3Answers: 0

    Everything works perfect when I only use 1 image field, but when I use 2 or more I always have the same error.

  • allanallan Posts: 61,438Questions: 1Answers: 10,051 Site admin

    Are you getting that error on load? Could you use the debugger to give me a trace please - click the Upload button and then let me know what the debug code is.

    Thanks,
    Allan

  • elherztelherzt Posts: 14Questions: 3Answers: 0

    Hi Allan, thanks for the reply, now I'm trying multiple upload, I think it makes more sense to upload multiple images.
    I have open a discussion in that topic.
    https://datatables.net/forums/discussion/61099/uncaught-unknown-file-table-name-with-multiple-upload

    Thanks.

  • dynasoftdynasoft Posts: 422Questions: 67Answers: 3

    Hi
    Is it possible to have 2 single file uploads on the same form? I get the same error: Uncaught Unknown file id 00 in table XX
    I can't use a multiple upload as the files are for different purposes. Please advise.

  • allanallan Posts: 61,438Questions: 1Answers: 10,051 Site admin

    Is it possible to have 2 single file uploads on the same form? I get the same error: Uncaught Unknown file id 00 in table XX

    Absolutely. As long as they have unique names, that should be absolutely fine. What version of Editor and the server-side libraries are you using? There was a bug around 1.9.0 I think whereby multiple uploads could cause themselves to overwrite data from the first field with that from the second. Bu the latest versions resolve that.

    Allan

  • dynasoftdynasoft Posts: 422Questions: 67Answers: 3

    Thanks

This discussion has been closed.