Search the Community
Showing results for tags 'uploading'.
-
I'm trying to create an upload form for my website- I want to restrict the allowed file types to WAV files and not allow any other file types. With the code I'm using, the form does not allow ANY file type. Why is this? Here's my script: <?php $target = "upload/"; $target = $target . basename( $_FILES['uploaded']['name']) ; $ok=1; if (!($uploaded_type == "audio/wav")) { echo "You may only upload WAV files.<br>"; $ok=0; } if ($ok==0) { Echo "Sorry your file was not uploaded"; } else { if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else { echo "Sorry, there was a problem uploading your file."; } } ?> of course when I comment out the bit " if (!($uploaded_type == "audio/wav")).... " it allows all file types, which I do not want. Thanks
-
Hello. I'm working on a website with an editor that allows image uploading. Ideally I want to be able to develop a framework for this and use it in later projects. What I have in mind is this: Database has an images table Entries contain these fields: id, filename, and a short description Images are referred to by their ids in other parts of the application. That part seems simple to me, but now there are two details I need to determine: the file name, and storing the images. Big sites like Facebook - as far as I know - parse uploads and store them all in the same format. I can see the huge security benefit there. What are the best ways of doing that? As for the file name, I know PHP has a function to generate a file with a unique name. Is there any benefit to doing that over using the id? (i.e. 1.jpg, 2.png, 3.jpg, etc)
-
Hey guys, I'm in the process of putting together a sign up form and I'm trying to figure out how to construct the page so that the user can first upload their avatar and then finish the form and create an account. Do you know how this is done logically? Do people upload the avatar via ajax and store it in some temperary folder after the photo has been uploaded? The problems is... if you're a user and you load the sign up page and upload a photo, after that photo gets upload via ajax and spit back out on the page, what happens? Does the photo get uploaded or are you just showing a desktop representation of that photo? Does the photo get uploaded when the full form is submitted? If the photo get's uploaded after an ajax call, how do you tie the uploaded photo to the signed up user after the form is submitted? Also, if the user uploads an avatar, but doesn't complete the form, how do you handle that situation? Do you know of any tutorials that outline this well? I'm essentially trying to implement the same functionality seen on pinterest's sign up form.