|
Has anyone come across this problem where firefox won't allow file uploads. On IE works fine.
Is there a workaround?
Thank you in advance.
|
|
|
|
|
No. There's almost certainly a problem with your code, which you haven't shown.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
My upload function code.
I did find a solution below you'll notice I force all upload files to be placed in the end user's C:\Temp folder. I also convert pdf files to an image before the encryption.
if (!String.IsNullOrEmpty(btnBrowse.FileName.ToString()))
{
if (fileExt == ".pdf")
{
pdfToJpg = @"c:\temp\" + btnBrowse.FileName.ToString().ToLower();
jpgOut = System.IO.Path.GetFileNameWithoutExtension(btnBrowse.FileName.ToString().ToLower());
jpgOut = @"c:\temp\" + jpgOut + ".jpg";
success = Utilities.Pdf2Jpg(pdfToJpg, jpgOut);
if (!success)
{
hdnFieldAlert.Value = "error; ERROR! File Not Converted.;Document Upload";
return;
}
imagePath = jpgOut;
savePath = appPath + saveDir + System.IO.Path.GetFileNameWithoutExtension(btnBrowse.FileName.ToString().ToLower()) + ".jpg";
}
sqlCmd = new SqlCommand("select legaldocurl from [dbo].[refugee] where [aregnum] = @clientNum", sqlCon);
sqlCmd.Parameters.Add("@clientNum", SqlDbType.VarChar).Value = oARegNum;
sqlCon.Open();
SqlDataReader dr = sqlCmd.ExecuteReader(CommandBehavior.CloseConnection);
if (dr.Read() && !String.IsNullOrEmpty(dr["legaldocurl"].ToString()))
{
prevUpload = dr["legaldocurl"].ToString();
prevUploadFile = appPath + saveDir + prevUpload;
if (File.Exists(prevUploadFile)) File.Delete(prevUploadFile);
if (File.Exists(savePath)) File.Delete(savePath);
}
string jpgFile = System.IO.Path.GetFileNameWithoutExtension(imagePath) + ".jpg";
fileToEncrypt = imagePath;
img = System.Drawing.Image.FromFile(fileToEncrypt);
Utilities.Encrypt(img, savePath);
img.Dispose();
sqlCon.Close();
sqlCmd = new SqlCommand("update [dbo].[refugee] set legaldocurl = @imgPath where [aregnum] = @clientNum", sqlCon);
sqlCmd.Parameters.Add("@imgPath", SqlDbType.VarChar).Value = jpgFile;
sqlCmd.Parameters.Add("@clientNum", SqlDbType.VarChar).Value = oARegNum;
sqlCon.Open();
sqlCmd.ExecuteNonQuery();
sqlCon.Close();
refugeeSelectByRecordId();
|
|
|
|
|
You mentioned uploading the images, which suggests to me that this is a web application.
You cannot use the FileName property of the FileUpload control to access the file. It returns the path - or sometimes just the name - of the file on the client. That file will not be accessible on the server, where your code is running.
It might appear to work when you debug your code in Visual Studio. But that's only because, in that specific cast, the server and client are the same computer. Once you deploy to a real server, your code will stop working.
Either use the SaveAs method to save the uploaded file to the server, or use the InputStream property to read the content of the uploaded file.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
due to security reasons I researched firefox does not return file location
so to circumvent this - upload files must be placed in the c:\temp folder.
Is there a better workaround?
|
|
|
|
|
You are doing it wrong. Read my previous message. You CANNOT access the client's file system from code running on the server!
Use the SaveAs method to save the uploaded file somewhere on your server. Or use the InputStream property to read the data from the uploaded file.
Trying to use the FileName property to read the file WILL NOT WORK!
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
H Richard, I added the function code to my help request.
|
|
|
|
|
I meant to add this.
The problem with FireFox is not, not allowing uploads but rather it does not show the path of the uploaded file just the name. to circumvent this - upload files must be placed in the c:\temp folder
|
|
|
|
|
Hi,
I need help for show datatable in Json
My project is MVC:
My AgendaModel
<pre> public List<AgendaModel> MostrarTodosCalendar()
{
List<AgendaModel> lista = new List<AgendaModel>();
AgendaModel item;
DAL objDAL = new DAL();
string sql = "SELECT id, title, start, end, AllDay, Color, TextColor FROM agenda";
DataTable dt = objDAL.RetDataTable(sql);
for (int i = 0; i < dt.Rows.Count; i++)
{
item = new AgendaModel
{
Id = dt.Rows[i]["Id"].ToString(),
Title = dt.Rows[i]["Title"].ToString(),
Start = dt.Rows[i]["Start"].ToString(),
End = dt.Rows[i]["End"].ToString(),
Color = dt.Rows[i]["Color"].ToString(),
TextColor = dt.Rows[i]["TextColor"].ToString()
};
lista.Add(item);
}
return lista;
}
My View: Index:
function CriarEventosCalendario() {
var events = [];
@{
foreach(var item in (List<AgendaModel>)ViewBag.ListaEventos)
{<text>events.push({
'id': @item.Id,
'title': '@item.Title',
'start': '@item.Start',
'end': '@item.End',
'allDay': false,
'color': '@item.Color',
'textColor': '@item.TextColor'
});</text>
}
}
I want to convert to JSON because fullcalendar is not showing the data as it currently is.
|
|
|
|
|
Change the events declaration in the view to
function CriarEventosCalendario() {
var events = @Html.Raw(Json.Encode(ViewBag.ListaEventos));
|
|
|
|
|
I have error in
Encode
You can help me ?
|
|
|
|
|
|
Erro CS1061 ‘IJsonHelper’ does not contain a definition for "Encode"..
|
|
|
|
|
You're using ASP.NET Core. Instead of:
var events = @Html.Raw(Json.Encode(ViewBag.ListaEventos)); use:
var events = @Json.Serialize(ViewBag.ListaEventos);
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
hello , guys I am working on hotel system can any body share source code with me please, its very important!
this's my email "showmore5@gmail.com"
thanks very much
|
|
|
|
|
No, nobody here is going to do your work for you.
And it's not "very important" to anyone other than you.
If you want to hire someone to write some code for you, there are sites where you can do that. This isn't one of them.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I worked on a booking system in the 90s, it took approx 18 months to build, not test just build. Mind you it is in SuperBase!
I can send you that code for a small recompense.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
I did laugh out loud at that!
I think I can probably find mine from the 80's - developed for C/PM though so probably a bit more expensive than yours
|
|
|
|
|
HAHAHAHA
Member 14921707 wrote: its very important!
If it was, you'd be paying and not begging.There's free solutions available. What makes you think I take the time to build you a new one, without pay?
How much time (aka money) do you think one needs to put into building one?
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
I'm sort of fuzzy on this here. So I have a HttpPost operation that ends with return Ok(result). I remember reading that I have to add a route to GetOrder in order for CreatedAtRoute to work. I sort of did something stupid and named that api GetAdminOrders so I can secure it with JWT, but added a Route decorator to it so CreatedAtRoute would work.
var result = CreatedAtRoute("GetOrder", new { order.Id }, order);
return Ok(result);
So this didn't work, it didn't return the order back to the client making the call. I just need the order number or Id of the order and not the whole order. Now I'm wondering if I should refactor all of these that I created. I'm really wondering if I got this all wrong here.
[HttpGet("GetAdminOrder/{orderId}"), Authorize(AuthenticationSchemes = AuthSchemes, Policy = AuthPolicies.Admin)]
[Route("{orderId}", Name = "GetOrder")]
public async Task<GetAdminOrder> GetAdminOrder(string orderId)
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
I flipped the 2 around, and changed the route to include the route decorator at the top of the controller.
I guess this route decorator wiped out the first route decorator.
[Produces("application/json")]
[Route("api/[controller]")]
[ApiController]
public class StoreController : ControllerBase
[Route("{orderId}", Name = "api/[controller]/GetOrder")]<br />
[HttpGet("GetAdminOrder/{orderId}"), Authorize(AuthenticationSchemes = AuthSchemes, Policy = AuthPolicies.Admin)]
public async Task<GetAdminOrder> GetAdminOrder(string orderId)
On this, it worked before, but since the .Net Core upgrade, it has changed. Now it sends the order wrapped in Url and Value. So I changed my client to expect a value of "any", and coded the expected order number and token as result.Value.OrderNumber
var result = CreatedAtRoute("GetOrder", new { order.Id }, order);
return Ok(result);
It works, not sure if it's fixed.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
jkirkerx wrote:
CreatedAtRoute("GetOrder", new { order.Id }, order)
...
HttpGet("GetAdminOrder/{orderId}") IIRC, the parameters passed to CreatedAtRoute need to have the same names as the route parameters.
Your route has orderId , but you parameters has just Id .
Try changing the parameters to match.
You don't need to add both HttpGet and Route attributes.
You should also return the CreatedAtRoute result directly, rather than wrapping it in an Ok result.
return CreatedAtRoute("GetOrder", new { orderId = order.Id }, order);
[HttpGet("GetAdminOrder/{orderId}", Name = "GetOrder"), Authorize(AuthenticationSchemes = AuthSchemes, Policy = AuthPolicies.Admin)]
public async Task<Order> GetAdminOrder(string orderId)
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I didn't think of it like that.
At the beginning before I wrote the JWT auth policies, I tried to make the app really code compact. It was just "GetOrder", then I renamed it to "GetAdminOrder" to reflect JWT Auth. I really need to streamline this naming.
return CreatedAtRoute directly? No need to return Ok. I wonder if using Ok wraps the JSON result in that extra envelope. I'll find out here, takes 10 mins to test it.
I made the code changes, and will give it a try, I'm sure it will work fine. I really don't want the extra route decorator anyways, it was just part of an example of using CreatedAtRoute I picked up over a year ago. I must admit that using CreatedAtRoute is pretty handy.
var result = CreatedAtRoute("GetAdminOrder", new { orderId = order.Id }, order);
return Ok(result);
[HttpGet("GetAdminOrder/{orderId}", Name = "GetOrder"), Authorize(AuthenticationSchemes = AuthSchemes, Policy = AuthPolicies.Admin)]
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
That worked out really well!
Thanks Richard
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
kindly help me to solve this issue.....i have Created a Login website - Validation Controls Registration Page but my submit button doesn't show message code i wrote which was:-
Response.Write("YOU HAVE SUCCESSFULLY REGISTERED...!!!!");
|
|
|
|