Last active
August 29, 2015 14:21
-
-
Save MikSDigital/c457a397cf0dbb20b2b1 to your computer and use it in GitHub Desktop.
Получает имя файла при отсылке через форму
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Contact form --> | |
<form id="contact-form" class="contact-form" name="" method="POST" action="http://site.ee/ru/message-sent.htm" enctype="multipart/form-data"> | |
<input type="hidden" name="MAX_FILE_SIZE" value="2000000" /> | |
<legend>Me koostame hinnapakkumise ja saadame selle Teile juba ühe tunni jooksul!</legend> | |
<div class="input-field"> | |
<input type="text" placeholder="Nimi:" value="" name="name" required> | |
</div> | |
<div class="input-field"> | |
<input type="text" placeholder="Telefon:" value="" name="phone" required> | |
</div> | |
<div class="input-field"> | |
<input type="email" placeholder="E-mail" value="" name="email"> | |
</div> | |
<div class="input-upload"> | |
<input type="file" name="attachment" value="" />Lisa fail</div> | |
<span id="attachment"></span> | |
<div class="input-field"> | |
<textarea placeholder="Kirjuta tekst siia" id="message" rows="15" name="message"></textarea> | |
</div> | |
<button type="submit" id="submit" name="submit">Saada päring</button> | |
</form> | |
<!-- Contact form --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('input[type="file"]').on('change', function (event, files, label) { | |
var file_name = this.value.replace(/\\/g, '/').replace(/.*\//, ''); | |
$('#attachment').text(file_name); | |
}); | |
$( "button" ).click(function() { | |
$( "#contact-form" ).submit(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment