472,779 Members | 2,266 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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("scripting.filesystemobject")
Set act = fso.CreateTextFile(server.mappath("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="multipart/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 2245
Try posting to the ASP newsgroup: microsoft.public.inetserver.asp.general.

--
HTH,

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

"Gavin" <Ga***@discussions.microsoft.com> wrote in message
news:D9**********************************@microsof t.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("scripting.filesystemobject")
Set act = fso.CreateTextFile(server.mappath("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="multipart/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(fileUpload.PostedFile.F ileName);
// Create a byte array to read contents of the file
byte[] Data = new Byte[fileUpload.PostedFile.ContentLength];
// Read the contents of the file into a stream
fileUpload.PostedFile.InputStream.Read(myData,0,fi leUpload.PostedFile.ContentLength);
// Save the stream to server
FileStream Stream = new FileStream(Path + FileName, FileMode.Create);
Stream.Write(Data,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***@discussions.microsoft.com> wrote in message
news:D9**********************************@microsof t.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("scripting.filesystemobject")
Set act = fso.CreateTextFile(server.mappath("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="multipart/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***@discussions.microsoft.com> wrote in message
news:D9**********************************@microsof t.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("scripting.filesystemobject")
Set act = fso.CreateTextFile(server.mappath("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="multipart/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
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...
2
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...
5
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...
4
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...
1
by: joe | last post by:
Any articles relating with Uploading images files to server and resize the image by asp.net 2.0
1
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...
14
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...
2
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...
7
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...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.