Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » Problem upload image with ASP
Closed Thread
Old 02-04-2004, 11:10 AM   #1 (permalink)
 
True Techie

Join Date: Feb 2004

Posts: 171

Discusman is on a distinguished road

Default Problem upload image with ASP

I'm pasting the code here, so plz test the code on ur server if u can. A very simple file upload program, it doesn't work on my server, but it works on other ppl's server

File name: Upload2New.asp
=====================
<%
Set Upload = Server.CreateObject("Persits.Upload.1")

Upload.OverwriteFiles = False
On Error Resume Next

Upload.SetMaxSize 1048576 ' Limit files to 1MB
Count = Upload.Save("c:\Inetpub\wwwroot\gallery")
%>
<HTML>
<BODY BGCOLOR="#FFFFFF">
<CENTER>

<% If Err <> 0 Then %>

<FONT SIZE=3 FACE="Arial" COLOR=#0020A0>
<H3>The following error occured while uploading:</h3>
</FONT>

<FONT SIZE=3 FACE="Arial" COLOR=#FF2020>
<h2>"<% = Err.Description %>"</h2>
</FONT>

<FONT SIZE=2 FACE="Arial" COLOR="#0020A0">
Please try again.
</FONT>

<% Else %>
<FONT SIZE=3 FACE="Arial" COLOR=#0020A0>
<h2>Success! <% = Count %> file(s) have been uploaded.</h2>
</FONT>

<FONT SIZE=3 FACE="Arial" COLOR=#0020A0>
<TABLE BORDER=1 CELLPADDING=3 CELLSPACING=0>
<TD>Image:</TD>
<% If Count > 0 Then %>
<%
Set File = Upload.Files(1)
If File.ImageType = "GIF" or File.ImageType = "JPG" or File.ImageType = "PNG" Then %>
<TD ALIGN=CENTER>[img]/uploaddir/<% = File.FileName%>[/img]
<% = File.OriginalPath%>

(<% = File.ImageWidth %> x <% = File.ImageHeight %> pixels)
</TD>
<% Else %>
<TD><% = File.OriginalPath %></TD>
<% End If %>
<% Else %>
<TD>File not selected.</TD>
<% End If %>
<TR>
<TD>Description:</TD><TD><% = Upload.Form("Description") %></TD><TR>
<TD>Categories:</TD>
<TD>
<%
For Each Item in Upload.Form
If Item.Name = "Category" Then Response.Write Item.Value & "
"
Next
%>
</TD>
</TABLE>


</FONT>



<FONT SIZE=2 FACE="Arial" COLOR=#0020A0>
Click here to upload more files.
</FONT>
<% End If %>

<HR>
<FONT SIZE=2 FACE="Arial" COLOR=#0020A0>
Download your trial copy of AspUpload.



Back to AspUpload.com.
</FONT>



</CENTER>
</BODY>
</HTML>
=================================
Here is the upload form:
File name:
=================================
<HTML>
<HEAD>
<TITLE>AspUpload Live Demo 2: Uploads of Files and Form Items</TITLE>
</HEAD>
<BODY>

<FONT FACE="Arial" size="2">

<H4>Uploads of Files and Form Items</h4>

Select a file, enter a description and select one or more categories.




<FORM METHOD="POST" ENCTYPE="multipart/form-data"
ACTION="upload2new.asp">
<TABLE CELLSPACING=0 CELLPADDING=3 BORDER=1>
<TD BGCOLOR="#FFFFCC">File:</TD>
<TD BGCOLOR="#FFFFCC"><INPUT TYPE=FILE SIZE=30 NAME="THEFILE"></TD><TR>
<TD BGCOLOR="#FFFFCC">Description:</TD>
<TD BGCOLOR="#FFFFCC"><INPUT TYPE=TEXT SIZE=30 NAME="Description"></TD><TR>
<TD BGCOLOR="#FFFFCC" VALIGN="TOP">Categories:</TD>
<TD BGCOLOR="#FFFFCC" VALIGN="TOP">
<SELECT NAME="Category" MULTIPLE>
<OPTION>Image
<OPTION>Text
<OPTION>Source Code
<OPTION>Archive
</SELECT>
</TD><TR>
<TD COLSPAN=2 BGCOLOR="#FFFFCC"><INPUT TYPE=SUBMIT VALUE="Upload"></TD>

</TD>
</TABLE>
</FORM>





Download source code for this demo

</FONT>
</BODY>
</HTML>
====================================
I get this error after I clicked upload button:
=======================
The page cannot be displayed
There is a problem with the page you are trying to reach and it cannot be displayed.

--------------------------------------------------------------------------------

Please try the following:

Open the www.nyc-discusfanatics.com home page, and then look for links to the information you want.
Click the Refresh button, or try again later.

Click Search to look for information on the Internet.
You can also see a list of related sites.




HTTP 500 - Internal server error
Internet Explorer
=============================
Discusman is offline  
Old 02-09-2004, 12:06 AM   #2 (permalink)
 
Wizard Techie

Join Date: Jul 2003

Posts: 3,940

ekÆsine

Default

you need to use the
PHP Code:
[PHP
[/PHP] tags so we can see your code or attach a text document to your post. i see garbage.
ekÆsine is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On