View Single Post
  #3 (permalink)  
Old 11-22-2008, 02:45 PM
Nitecon Nitecon is offline
Junior Member
 
Join Date: Nov 2008
Posts: 14
Default

I do realize it will use it's own name, but there are 2 problems here.

1. The form automatically calls the fromRename() function on initialization not on submit...

2. I need to change the file name, and at the same time get the extension, since I am allowing 3 different extensions for upload.

So... if userx for instance uploads Myname.jpg, I need to parse the entire file with extension, rename the file to 1_photo.jpg, while keeping the extension as is. That way when userY uploads APhoto.gif, I can still get the extension. The first part is easy. It's getting the actual extension. So the way I see it there can be 2 solutions to this problem... The first being to find a way to hook the actual file name "onchange" (as in when the user hits the browse button and the value changes to something that is NotEmpty) or by adding some sort of filter or validator or action to getExtension on the particular form field.

Now here is the swing part of it, if the user does not decide to upload a picture, because of the fact that the formRename() runs on init, there will automatically be a value, so the form element will automatically upload an empty file, so there has to be a check instead of using NotEmpty, but rather something like NotEmpty && OnChange.

If this doesn't make any sense try it out yourself, I have tried just about everything so far, but I just can't find a way to get the extension
Reply With Quote