brosskgm Posted April 8, 2012 Share Posted April 8, 2012 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> Quote Link to comment https://forums.phpfreaks.com/topic/260574-select-file-name-and-send-name-only/ Share on other sites More sharing options...
dcro2 Posted April 8, 2012 Share Posted April 8, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/260574-select-file-name-and-send-name-only/#findComment-1335440 Share on other sites More sharing options...
brosskgm Posted April 8, 2012 Author Share Posted April 8, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/260574-select-file-name-and-send-name-only/#findComment-1335464 Share on other sites More sharing options...
brosskgm Posted April 8, 2012 Author Share Posted April 8, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/260574-select-file-name-and-send-name-only/#findComment-1335466 Share on other sites More sharing options...
dcro2 Posted April 8, 2012 Share Posted April 8, 2012 Can you take out that part? That'll prevent the browser from actually uploading the file. Quote Link to comment https://forums.phpfreaks.com/topic/260574-select-file-name-and-send-name-only/#findComment-1335469 Share on other sites More sharing options...
brosskgm Posted April 8, 2012 Author Share Posted April 8, 2012 Ok. that's easy enough. Is there anything I need to do so it sends the file name selected with the submit button? Can you take out that part? That'll prevent the browser from actually uploading the file. Quote Link to comment https://forums.phpfreaks.com/topic/260574-select-file-name-and-send-name-only/#findComment-1335474 Share on other sites More sharing options...
dcro2 Posted April 8, 2012 Share Posted April 8, 2012 No. Just select a file and it'll send the file name when you submit. Quote Link to comment https://forums.phpfreaks.com/topic/260574-select-file-name-and-send-name-only/#findComment-1335476 Share on other sites More sharing options...
brosskgm Posted April 8, 2012 Author Share Posted April 8, 2012 It didn't send the name. Most likely I don't know what param to give it and put in the cgi so it process it. No. Just select a file and it'll send the file name when you submit. Quote Link to comment https://forums.phpfreaks.com/topic/260574-select-file-name-and-send-name-only/#findComment-1335478 Share on other sites More sharing options...
brosskgm Posted April 8, 2012 Author Share Posted April 8, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/260574-select-file-name-and-send-name-only/#findComment-1335483 Share on other sites More sharing options...
brosskgm Posted April 8, 2012 Author Share Posted April 8, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/260574-select-file-name-and-send-name-only/#findComment-1335485 Share on other sites More sharing options...
brosskgm Posted April 8, 2012 Author Share Posted April 8, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/260574-select-file-name-and-send-name-only/#findComment-1335486 Share on other sites More sharing options...
brosskgm Posted April 9, 2012 Author Share Posted April 9, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/260574-select-file-name-and-send-name-only/#findComment-1335488 Share on other sites More sharing options...
dcro2 Posted April 9, 2012 Share Posted April 9, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/260574-select-file-name-and-send-name-only/#findComment-1335491 Share on other sites More sharing options...
brosskgm Posted April 9, 2012 Author Share Posted April 9, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/260574-select-file-name-and-send-name-only/#findComment-1335501 Share on other sites More sharing options...
brosskgm Posted April 9, 2012 Author Share Posted April 9, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/260574-select-file-name-and-send-name-only/#findComment-1335509 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.