473,748 Members | 2,274 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Uploading images to web server

I need some help, I need the code to allow people that visit my website to be
able to upload pictures to a file on my web server. I have been able to get
close, but not quite there yet.

Set fso = createobject("s cripting.filesy stemobject")
Set act = fso.CreateTextF ile(server.mapp ath("test.jpg") , true)
act.WriteLine
act.Close

The above code will create the file but will not write any data in it. Below
is the htm code that lets the user upload the file.

<form method="post" action="" name="submit" enctype="multip art/form-data">
Choose A File: <input type="file" name="filefield "><br><br>
<input type="submit" name="submit" value="submit"> <br>
</form>
The problem is I can't get the upload image file information to pass
between the htm page to the asp page in a form that it can be written to a
file. I am also not sure that I am using the correct asp code since it is not
a text file I am trying to write. But it is the only code I can find. I do
not need to check to see if the file exits or anything else. All I need is to
upload an image from the htm page pass it to the asp page in the correct form
to be written then write it directly to my web server.

Thanks for you help

Jan 22 '06 #1
3 2313
Try posting to the ASP newsgroup: microsoft.publi c.inetserver.as p.general.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Who is Mighty Abbott?
A twin turret scalawag.

"Gavin" <Ga***@discussi ons.microsoft.c om> wrote in message
news:D9******** *************** ***********@mic rosoft.com...
I need some help, I need the code to allow people that visit my website to
be
able to upload pictures to a file on my web server. I have been able to
get
close, but not quite there yet.

Set fso = createobject("s cripting.filesy stemobject")
Set act = fso.CreateTextF ile(server.mapp ath("test.jpg") , true)
act.WriteLine
act.Close

The above code will create the file but will not write any data in it.
Below
is the htm code that lets the user upload the file.

<form method="post" action="" name="submit" enctype="multip art/form-data">
Choose A File: <input type="file" name="filefield "><br><br>
<input type="submit" name="submit" value="submit"> <br>
</form>
The problem is I can't get the upload image file information to pass
between the htm page to the asp page in a form that it can be written to a
file. I am also not sure that I am using the correct asp code since it is
not
a text file I am trying to write. But it is the only code I can find. I do
not need to check to see if the file exits or anything else. All I need is
to
upload an image from the htm page pass it to the asp page in the correct
form
to be written then write it directly to my web server.

Thanks for you help

Jan 23 '06 #2
Uploading images is a very easy procedure. You don't actually have to make a
file and write the contents on it. Rather you can just save the image your
user wants to upload. Here's the piece of code that will do the work for
you:

// The path where you want to store the images
string Path = Server.MapPath( "images/");
// Filename of the image from fileupload html control with id "fileUpload "
string FileName =
System.IO.Path. GetFileName(fil eUpload.PostedF ile.FileName);
// Create a byte array to read contents of the file
byte[] Data = new Byte[fileUpload.Post edFile.ContentL ength];
// Read the contents of the file into a stream
fileUpload.Post edFile.InputStr eam.Read(myData ,0,fileUpload.P ostedFile.Conte ntLength);
// Save the stream to server
FileStream Stream = new FileStream(Path + FileName, FileMode.Create );
Stream.Write(Da ta,0, myData.Length);
Stream.Close();

Aboe code is in C#, you can convert it into VB.NET as per your requirement.
I hope it will be helpful.

Zeeshan.
http://zishu.blogspot.com
"Gavin" <Ga***@discussi ons.microsoft.c om> wrote in message
news:D9******** *************** ***********@mic rosoft.com...
I need some help, I need the code to allow people that visit my website to
be
able to upload pictures to a file on my web server. I have been able to
get
close, but not quite there yet.

Set fso = createobject("s cripting.filesy stemobject")
Set act = fso.CreateTextF ile(server.mapp ath("test.jpg") , true)
act.WriteLine
act.Close

The above code will create the file but will not write any data in it.
Below
is the htm code that lets the user upload the file.

<form method="post" action="" name="submit" enctype="multip art/form-data">
Choose A File: <input type="file" name="filefield "><br><br>
<input type="submit" name="submit" value="submit"> <br>
</form>
The problem is I can't get the upload image file information to pass
between the htm page to the asp page in a form that it can be written to a
file. I am also not sure that I am using the correct asp code since it is
not
a text file I am trying to write. But it is the only code I can find. I do
not need to check to see if the file exits or anything else. All I need is
to
upload an image from the htm page pass it to the asp page in the correct
form
to be written then write it directly to my web server.

Thanks for you help

Jan 23 '06 #3
Gavin you can just re write your code in ASP.NET
It will make life easier for you.
Patrick
"Gavin" <Ga***@discussi ons.microsoft.c om> wrote in message
news:D9******** *************** ***********@mic rosoft.com...
I need some help, I need the code to allow people that visit my website to be able to upload pictures to a file on my web server. I have been able to get close, but not quite there yet.

Set fso = createobject("s cripting.filesy stemobject")
Set act = fso.CreateTextF ile(server.mapp ath("test.jpg") , true)
act.WriteLine
act.Close

The above code will create the file but will not write any data in it. Below is the htm code that lets the user upload the file.

<form method="post" action="" name="submit" enctype="multip art/form-data">
Choose A File: <input type="file" name="filefield "><br><br>
<input type="submit" name="submit" value="submit"> <br>
</form>
The problem is I can't get the upload image file information to pass
between the htm page to the asp page in a form that it can be written to a
file. I am also not sure that I am using the correct asp code since it is not a text file I am trying to write. But it is the only code I can find. I do
not need to check to see if the file exits or anything else. All I need is to upload an image from the htm page pass it to the asp page in the correct form to be written then write it directly to my web server.

Thanks for you help

Jan 23 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2712
by: laredotornado | last post by:
Hi, I'm using PHP 4 and I am submitting some images in a form with <form name=addProductForm enctype="multipart/form-data" method=post action="add_product_response.php"> <input type=file name='prodImg' id='prodImg'> However, sometimes, the images fail to upload, even though the form submits fine. When I try to print out the values from the $_FILES array, I get
2
1875
by: Paul Gorman | last post by:
I am using the control type = file to perform a file upload. When I click on the browse button to go select the image I want to upload it places in the text box a local path (C:\images\image.jpg for example). This is where the image resides that I want to upload. Then I proceed to click on upload so that I can run through my code to do the upload process: string strConnection = "some connection string"; SqlConnection oCon = new...
5
3113
by: Grant Harmeyer | last post by:
I have an application that uses FreeTextBox 2.0 (http://www.freetextbox.com). FreeTextBox is a rich text editor that behaves similarly to MS Word. The FreeTextBox control has a button to insert images (just as you would with MS Word) and it works beautifully. The problem is that when you include an image with the rich text editor, the image path is the local path on the client. I have written a method that examines the text for <img> tags,...
4
1651
by: Ramakrishnan Nagarajan | last post by:
Hi, I am facing a different problem in my application. In that I am uploading a folder that contain only images. Everything was done and was working fine too. When I executed the application using the localhost it works fine. But when my machine acts as a client and executes the application from another machine (considered as the server) it is telling that the folder is not found, even if the folder is present in the client machine. The...
1
2161
by: joe | last post by:
Any articles relating with Uploading images files to server and resize the image by asp.net 2.0
1
2195
by: Nerry | last post by:
Hello everyone, I have ASP webpages, but I have a problem uploading my images via ftp, keep getting an error: An error occurred copying a file to the ftp server. Make sure you have permissions to put files on the server. Details: The operation timed out. Anyone ever had that problem? Please help! thanks.
14
4479
w33nie
by: w33nie | last post by:
What I'm trying to do here, is upload a video to the ../video/ folder, and up to 5 images to the ../images/ folder. As well as the database information like title, content and each file's file information. But I really have no idea how to do this. The whole move_uploaded_file part is obviously wrong, but I'm not sure where to go from here to achieve my ends. $videoUploadDir = '../video/'; $imageUploadDir = '../images/'; ...
2
2042
by: lavadan | last post by:
Hi Folks, I am a newbie to SQL Server. Please help me with this. I have some tiff files. I have to upload them into sql server. How do i do this. I will be getting the tiff files in a hardware and from there i have to load these images into sql server. Is it a good idea to load the entire images into the database or just the pointers to the images. My manager said that they want to load the images into respective folders. But i think...
7
2489
by: nwclark | last post by:
Ok... I have a noobie issue. I am trying to upload a photo to specific directory on my server. (this is working correctly with the code below). However, I am also trying to rename the file and upload that filename to a mysql database (users.photo). This is my code.. it shows no errors but it does not add it to my server. HELP WOULD BE SO APPRECIATED!!\
0
9552
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9376
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9326
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6796
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6076
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4877
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3315
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2787
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.