|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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 Alternatives” Download Now! |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
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 |
|
#4
|
|||
|
|||
|
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 |
|
#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 |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Problems renaming jpg files on upload |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|