ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Learn four approaches for automating Excel logic, along with advantages and disadvantages of each. Read all about it in the free whitepaper: “Tapping into Excel Logic from Java: Four Server-Based AlternativesDownload Now!
  #1  
Old August 14th, 2003, 10:27 AM
Jonny5uk Jonny5uk is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 62 Jonny5uk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 9 m 10 sec
Reputation Power: 6
Problems renaming jpg files on upload

Hi there,

I've got a bit of a problem with renaming jpeg files that I'm uploading via the 'aspupload' component. The actual process itself works fine with gifs but not with jpgs.

What happens is that I'm renaming the files on upload to match the session ID so that they can be identified. As I said, this works fine with gifs and hold the extension for gifs and jpgs.

The problem is that when I upload and rename a jpg using the forementioned process, it seems to not actually save it properly as when I try to open it, it seems to have lost all file information about it, i.e. no file type listed in properties of image and it has also lost size. Also when I drag it into IE it will not display.

Has anyone else found this problem or have any ideas on how to get round this? As I need to be able to rename jpgs and gifs, so its really important.

Heres my ASP code, if it helps...

<%
Set Upload = Server.CreateObject("Persits.Upload.1")
Upload.OverwriteFiles = False
Upload.Save(server.mappath("/images/awaiting_prep/wheels/"))
NewName = Session.SessionID
%>

<%
For Each File in Upload.Files
File.Copy (server.mappath("/images/awaiting_prep/wheels/") & NewName & File.ext)
File.Delete
Response.Write "New name: " & NewName & File.ext & "<BR>"
Next
%>


If anyone could help with this, it would be much appreciated !!

Kind regards

Jon

Reply With Quote
  #2  
Old August 14th, 2003, 10:53 AM
Vlince Vlince is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Canada, Quebec, Montreal
Posts: 410 Vlince User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
I've looked here:
http://www.aspupload.com/manual_image.html

and in the first paragraph it reads:
The formats currently supported are GIF, JPEG, BMP and PNG

Perhaps they show, in the documentation OR on their web site, and example that works...

I'll/you'll might want to check that!

Hope this helps!
Sincerely

Vlince

Reply With Quote
  #3  
Old August 14th, 2003, 11:59 AM
unatratnag unatratnag is offline
Average Intelligence
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2003
Location: Ohio/Chicago
Posts: 678 unatratnag User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 22 sec
Reputation Power: 6
Send a message via AIM to unatratnag
if you possess the ability to use .net, here's an old script i use to rename files on an upload, and if you can't... then don't read anymore.

sorry, but i don't really want to clean in up just in case i break it, so just fix it up as you needs be, this makes sure it's a vcs or xml file before uploading. But in anycase, the function rename(c) is what you use to rename the file, just return the new file name (and yes i've used it with jpg, jpegs etc).

<Script Language="VB" RunAt="Server">


Sub Upload_Click(Sender as Object, e as EventArgs)

' Display properties of the uploaded file

FileName.InnerHtml = MyFile.PostedFile.FileName
FileContent.InnerHtml = MyFile.PostedFile.ContentType
FileSize.InnerHtml = MyFile.PostedFile.ContentLength
UploadDetails.visible = True

' recover only the file name from its fully qualified path at client

Dim strFileName as string
strFileName = MyFile.PostedFile.FileName
Dim c as string = System.IO.Path.GetFileName(strFileName) ' only the attched file name not its path
Dim d = split(c, ".")
dim delim
delim =""
if ((strFileName ="") or (d.length = 1)) then
delim="nogo"
else if d(1) = "csv" then
delim=","
else if d(1) = "xml" then
delim="#"
end if
if (delim="," OR delim="#") then
Try
' Save uploaded file to server at ServerFolder
' Will overwrite file, no error checking done
c=call rename(c)
MyFile.PostedFile.SaveAs("E:\temp\" + c)
Span1.InnerHtml = "Your File Uploaded Sucessfully at server as : E:\temp\" & c
Span1.visible = true

' On Error
catch Exp as exception
span1.InnerHtml = "An Error occured. Please check the attached file"
UploadDetails.visible = false
span2.visible=false
End Try
else
Span1.innerhtml = "sorry, please upload only XML or CSV files"
Span1.visible=true
UploadDetails.visible=false
end if
End Sub 'end of upload click subfunction

Reply With Quote
  #4  
Old August 14th, 2003, 06:45 PM
Jonny5uk Jonny5uk is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 62 Jonny5uk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 9 m 10 sec
Reputation Power: 6
Thanks for replies....

Hi there,

thanks for the replies....

Vlince, I had looked at the manual prior to posting but couldn't find any mention of the problem I have. Have also check their support area but no joy there either.

The chapter you mentioned, basically just seems to display what file type the image is, but doesn't rename it. I have tried changing the code but unfortunately to no avail.

My code seems to support jpg uploading, but obviously i'm getting this problem after renaming the file on upload.

Not too sure where to go from here !

unatratnag; thanks for the reply, unfortunately my hosting package doesn't have .net on it. But thanx for posting the code.

Hopefully someone else out there might have a solution !??

If so, any further help would be really appreciated.

Kind regards

Jon

Reply With Quote
  #5  
Old August 14th, 2003, 08:02 PM
Vlince Vlince is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Canada, Quebec, Montreal
Posts: 410 Vlince User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
How about emailing their support? no?
I'm sure you're not the first one having such a problem!

Could it be that you need certain rights?
Nah...nonsense...forget that

Otherwise, besides my best friend google.com and can't rellay help ya

Vlince

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Problems renaming jpg files on upload


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway