Jump to content

Select file name and send name only


brosskgm

Recommended Posts

I use WYSIWYG Web Builder. They have a file upload option in their form wizard. But I don't want to upload the file. I only want the name of the selected file sent on submit. No matter what I try it keeps trying to send the file, or just sends a blank when I remove the var

 

I've looked though the code and this is the only parts I can find that have anything to do with the file upload. There will be more than one select B1-File, B2-File, B3-File etc....

 

I put one here.

 

I only want to get the file name that is selected not the file to be sent to the server. If someone knows of an easier way to use a file select/browse button and get the file name only and wouldn't mind sharing it. Thanks

 

I have been searching for a solution and have not been able to find the one.

 

Thanks

Bob

 


function ValidateForm1(theForm)
{

var extension = theForm.FileUpload2.value.substr(theForm.FileUpload2.value.lastIndexOf('.'));
   if ((extension.toLowerCase() != ".avi") &&
       (extension.toLowerCase() != ".doc") &&
       (extension.toLowerCase() != ".gif") &&
       (extension.toLowerCase() != ".jpg") &&
       (extension.toLowerCase() != ".mov") &&
       (extension.toLowerCase() != ".mp3") &&
       (extension.toLowerCase() != ".mp4") &&
       (extension.toLowerCase() != ".mpeg") &&
       (extension.toLowerCase() != ".pdf") &&
       (extension.toLowerCase() != ".qt") &&
       (extension.toLowerCase() != ".rtf") &&
       (extension != ""))
   {
      alert("The \"FileUpload2\" field contains an unapproved filename.");
      theForm.FileUpload2.focus();
      return false;
   }
   return true;

}

<body>
<div id="container">

<input type="file" id="FileUpload2" class="Heading 5 <h5>" style="position:absolute;left:455px;top:592px;width:238px;height:22px;z-index:42" name="B1-File">

</form>
</div>
</body>
</html>

Link to comment
Share on other sites

I can't see where you initiated the <form>, but there is an attribute like this in it, right?

enctype="multipart/form-data"

Well, just remove that part from the <form> and all that will be submitted is the filename instead of the file.

Link to comment
Share on other sites

I'll look. The web builder does most of it.

 

I can't see where you initiated the <form>, but there is an attribute like this in it, right?

enctype="multipart/form-data"

Well, just remove that part from the <form> and all that will be submitted is the filename instead of the file.

Link to comment
Share on other sites

Yes there is

 

<form name="Form1" method="post" action="http://192.168.4.4/cgi-bin/GenerateRequest.cgi" enctype="multipart/form-data"

id="Form1" onsubmit="return ValidateForm1(this)">

 

I can't see where you initiated the <form>, but there is an attribute like this in it, right?

enctype="multipart/form-data"

Well, just remove that part from the <form> and all that will be submitted is the filename instead of the file.

Link to comment
Share on other sites

That was it. It's working. Wow!!, that easy.

 

I mean FileUpload1,

 

I tried param B1-File, FileUpload2 and also put txtB1-File, txtFileUpload2 in the cgi but those didn't work.

 

 

No. Just select a file and it'll send the file name when you submit.

Link to comment
Share on other sites

I'm really surprised the Web Builder people didn't want to tell me that. They said it required a different form processor to do that.

 

Thank you so much. I've been banging my head trying to find something to work.

 

Thanks

Bob

 

 

That was it. It's working. Wow!!, that easy.

 

I mean FileUpload1,

 

I tried param B1-File, FileUpload2 and also put txtB1-File, txtFileUpload2 in the cgi but those didn't work.

 

 

No. Just select a file and it'll send the file name when you submit.

Link to comment
Share on other sites

This little thing was no where to be fond on the internet. It will now.

 

Now I'll be testing 6 file selections on one form and see how it does shortly.

 

I didn't know it myself until I tried to test something else and forgot to add the enctype attribute. It was an interesting find.

Link to comment
Share on other sites

Worked great with multiple file names selected.

 

This will make things so much easier than typing the name of each file.

 

Thank you again.

Bob

 

 

I didn't know it myself until I tried to test something else and forgot to add the enctype attribute. It was an interesting find.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.