File uploaded to a field that does not have upload options configured
File uploaded to a field that does not have upload options configured
azonekz@gmail.com
Posts: 32Questions: 9Answers: 1
Hi, when I'm trying to upload a file I have an error: "File uploaded to a field that does not have upload options configured". Help me please
Controller:
public ActionResult JTovar()
{
var request = System.Web.HttpContext.Current.Request;
var settings = Properties.Settings.Default;
using (var db = new DataTables.Database(settings.Dbtype, settings.DbConnection))
{
var response = new Editor(db, "Tovar", "id")
.Model<ModelTovar>()
.Field(new Field("Tovar.id"))
.MJoin(new MJoin("image")
.Link("Tovar.id", "interImage.idTovar")
.Link("image.id", "interImage.idImage")
.Model<MjoinImageTovar>()
.Field(
new Field("Tovar.Links")
.Upload(
new Upload(request.PhysicalApplicationPath + @"uploads\__ID____EXTN__")
.Db("image", "id", new Dictionary<string, object>
{
{"fileName", Upload.DbType.FileName},
{"fileSize", Upload.DbType.FileSize},
{"webPath", Upload.DbType.WebPath},
{"systemPath", Upload.DbType.SystemPath}
})
.Validator(Validation.FileSize(50000000, "Max file size is 500000K."))
.Validator(Validation.FileExtensions(new[] { "jpg", "png", "gif","html","htm" }, "Please upload an image or html file."))
)
.SetFormatter(Format.NullEmpty())
)
)
.Process(request)
.Data();
return Json(response, JsonRequestBehavior.AllowGet);
}
}
{
label: "Links:",
name: "Tovar.Links",
type: "uploadMany",
display: function (id) {
return '<img src="' + editor.file('image', id).webPath + '"/>';
},
noImageText:'No image'
}
------------------------------------------------------------------------------------------------------
{
data: "Tovar.Links",
render: function (data)
{
console.log(data);
return data?
data.length + ' files(s)' :
'No file';
},
title: "Image"
}
--------------------------------------------------------------------------------------------------------
Models:
public class MjoinImageTovar
{
public class interImage
{
public int id { get; set; }
public int idTovar { get; set; }
public int idImage { get; set; }
}
public class image
{
public int id { get; set; }
public string fileName { get; set; }
public int fileSize { get; set; }
public string webPath { get; set; }
public string systemPath { get; set; }
}
}
public class ModelTovar
{
public class Tovar
{
public int id { get; set; }
public string Links { get; set; }
}
Edited by Allan Formatting using markdown.
This discussion has been closed.
Answers
Can you show me your db schema please? I'm a little confused by the use of
uploadMany
for a field that is not in an mJoin.Allan
Help me please to find out what is wrong with my code.
Thanks - I believe the issue is that the upload should actually be on the Mjoin. For example:
Is the C# version of the PHP upload many example.
For the upload many field on the client-side you want to use:
since
image
is the array of items for the files.Allan
Thanks for response Allan.
Upload was already on the Mjoin. I changed code like you advised:
Controller:
Now it's working for uploading many files, but when I'm trying to update a row with already uploaded files I have an error:
dataTables.editor.min.js:12 Uncaught Unknown file table name: image
I don't understand how to fix it. Thanks.
Hi,
I am suffering from another problem.
I can't get information about uploaded file.
if editor.file('image') is called, then it returns error message "Unknown file table name: image". If editor.files() is called, then it returns empty object -> { }
Can you help me, please?
I use editor 1.8.1
Can you show me the JSON being returned by the server when the table is first loaded? Even better would be a link to the page showing the issue so I can debug it.
Thanks,
Allan
Yes, sure, the link is: http://tfl.igyrus.com/Tables/Tovar
Please, create a new entity with (downloaded image), refresh the page and try to edit this entity.
Thanks in advance.
Thanks for the link. I'm getting an error though:
That's interrupting the Javascript and nothing else is happening (as the main code us attempting to do
new $.fn.dataTable.Editor(...)
which is failing).Allan
Thanks for reponse. Try it now again, please.
Hi Allan.
Can you check it again, please?
Thank you. When the page is reloaded I see
files: {}
in theJTovar
JSON response, so Editor is correct on the client-side in reporting the error it is. That object should contain information about the file(s). See this section of the docs.You can also see the expected behaviour by experimenting with the demo upload page.
Allan
Sorry - I'd forgotten you were using the .NET libraries for Editor. Can you show me the full Controller please?
Thanks,
Allan
Controller:
Hi Allan,
can you check it, please?