473,395 Members | 1,696 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

mysterious file upload

3
hi, i have a simple html objects like
Expand|Select|Wrap|Line Numbers
  1. <INPUT type=file id=File1 name=File1 runat="server" visible="true" ><br />
  2. <input type="submit" id="Submit1" value="Salveaza" runat="server" NAME="Submit1" >
  3.  
in an .net application, it should upload files on server;
Expand|Select|Wrap|Line Numbers
  1. if (Directory.Exists(caleSave))
  2.                 {
  3.                     caleSave += "\\";
  4.  
  5.   if ((File1.PostedFile != null) && (File1.PostedFile.ContentLength > 0))
  6.                     {
  7.  string fn = System.IO.Path.GetFileName(File1.PostedFile.FileName);
  8.                         string SaveLocation = caleSave + fn;
  9.                         try
  10.                         {
  11.                             File1.PostedFile.SaveAs(SaveLocation);
  12.                             lblEroare.Text = "Document saved successfully!";
  13.                         }
  14.                         catch (Exception ex)
  15.                         {
  16.                             lblEroare.Text = "Error " + ex.Message;                            
  17.                         }
  18.                     }
  19.                     else
  20.                     {
  21.                         lblError.Text = "Select a file!!!";
  22.                         lblError.ForeColor = System.Drawing.Color.Red;
  23.                     }
  24.                 }
  25.  
what i am doing wrong?? beacause this code doesn't upload on the first time but only second time it always works!

i'm using ajax extension for .net, with refresh... may be here is the problem?
Feb 29 '08 #1
4 1060
Plater
7,872 Expert 4TB
Are any exceptions thrown? What do you mean by "fail"?
And yes, I might guess there is something to do with the way ajax sends data, but it should still work.
Feb 29 '08 #2
kron84
3
only exeption is that it never passes this if condition
if ((File1.PostedFile != null) && (File1.PostedFile.ContentLength > 0))
{bla bla}
Mar 5 '08 #3
Plater
7,872 Expert 4TB
Does your ajax object make sure to use the correct POST style for form-multipart?
Mar 5 '08 #4
kron84
3
how can I set in SharePoint ajax form enctype? I'm publishing the control as a SmartPart with Ajax.
Mar 6 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: matt | last post by:
I have compiled some code, some written by me, some compiled from various sources online, and basically i've got a very simple flat file photo gallery. An upload form, to upload the photos and give...
13
by: Sky Sigal | last post by:
I have created an IHttpHandler that waits for uploads as attachments for a webmail interface, and saves it to a directory that is defined in config.xml. My question is the following: assuming...
2
by: mark | last post by:
How do I detect that a particular form element is a file upload or if the file upload has worked? In the Python cgi module documentation I found suggested code... form = cgi.FieldStorage()...
33
by: Martin Jørgensen | last post by:
Hi, In continuation of the thread I made "perhaps a stack problem? Long calculations - strange error?", I think I now got a "stable" error, meaning that the error always seem to come here now...
7
by: pbd22 | last post by:
hi. i am having probs understanding how to grab a file being uploaded from a remote client. i am using hidden input fields for upload such as: <input id="my_file_element" type="file"...
2
by: hotflash | last post by:
Hi All, I found the best pure ASP code to upload a file to either server and/or MS Access Database. It works fine for me however, there is one thing that I don't like and have tried to fix but...
1
by: chrisj | last post by:
I'm using freeASPupload and got some assistance integrating to a Member script. It works successfully. In this modified version there are two groups that use this upload script. Members of one...
6
Jacotheron
by: Jacotheron | last post by:
I need a PHP script that can upload music files (mp3). The script is for a home project I have started a while ago. I have a MySQL database of all the music that I have. Other computers on the...
7
Curtis Rutland
by: Curtis Rutland | last post by:
Building A Silverlight (2.0) Multi-File Uploader All source code is C#. VB.NET source is coming soon. Note: This project requires Visual Studio 2008 SP1 or Visual Web Developer 2008 SP1 and...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.