Created
April 19, 2022 15:53
-
-
Save NickyAlan/77a66bf135c9be1bac9f2c12e7d73234 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
crete media folder with piority same as static folder | |
[settings.py] | |
import os | |
MEDIA_ROOT = os.path.join(BASE_DIR, 'media') | |
MEDIA_URL = '/media/' | |
[urls.py] at main project | |
from django.conf import settings | |
from django.conf.urls.static import static | |
if settings.DEBUG : | |
urlpatterns += static(settings.MEDIA_URL, root=settings.MEDIA_ROOT) | |
[html] | |
<form method="POST" enctype="multipart/form-data"> | |
{% csrf_token %} | |
<input type='file' name="fileName"> | |
<button type="submit">Upload</button> | |
</form> | |
[views.py] | |
if request.method == 'POST' : | |
try : | |
data = request.POST.copy() | |
except : | |
return render(request,'app/speechtotext.html') | |
file = request.FILES['fileName'] | |
fs = FileSystemStorage() | |
fs.save(flie.name,file) | |
...open(media/speech_data.wav)... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment