awiedman Posted October 18, 2008 Share Posted October 18, 2008 I been trying to make a multiple file upload with restrictions that only allow you to upload .gif, .jpg, .png, .mp3, .wav, and .mid file types. So if someone could help me or supply a code that would be great. Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted October 18, 2008 Share Posted October 18, 2008 You can't upload multiple files at the same time, unless you use something like jQuery or Prototype. We're not going to supply you with code either, at least attempt to make it then post the code that isn't working here and we'll take a look. Remember to tell us why it isn't working. To start, have a look at the manual. It has some examples. Quote Link to comment Share on other sites More sharing options...
Acs Posted October 18, 2008 Share Posted October 18, 2008 I don't think using prototype or jquery will do what awiedman wants. Try using SWFUpload -> http://swfupload.org/ I don't think this will work in the new flash (10.0) Quote Link to comment Share on other sites More sharing options...
awiedman Posted October 19, 2008 Author Share Posted October 19, 2008 So far this is what I have, but I can't figure out how to make it for it restricts certain format/filetypes and to make it multi upload. Index.html <html> <head> <title>Upload Media</title> </head> <body> <center> <table cellspacing="0" border="1" bordercolor="black"> <tr><td background="http://rphosting.net/dir_images/tableheader.png" colspan="2"><center><font color="white">Upload Media</font></td> </tr> <tr> <td><form enctype="multipart/form-data" action="uploader.php" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="120000000" /> Choose a file to upload: <input name="uploadedfile" type="file" /><br /> <input type="submit" value="Upload File" /> </form></td> Uploader.php <center> <table cellspacing="0" border="1" bordercolor="black"> <tr><td background="http://rphosting.net/dir_images/tableheader.png" colspan="2"><center><font color="white">Upload Media</font></td></tr> <tr> <td> <?php $target_path = "/home/rphost/public_html/upload/"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } ?> </td> </tr> <tr> <td> <br> <small>File Name:</small><br> <?php echo "<input type='text' size='25' onclick='javascript:select();' value='". basename( $_FILES['uploadedfile']['name']). "'>";?> <br> Preview:<br> <?php echo "<img src='http://rphosting.net/uploads/". basename( $_FILES['uploadedfile']['name']). "'>";?></td> </tr> <tr> <td><center><form action="index.php" method="post"><input type="submit" value="Return to Upload Page"></center></td> </tr> </table> Uploads folder must have file permissions of 777 But i also found this code at: http://www.w3schools.com/php/php_file_upload.asp It's supposed to put restricions on it but I can't figure out how to apply it to my upload script <?php if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 20000)) { if ($_FILES["file"]["error"] > 0) { echo "Error: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Stored in: " . $_FILES["file"]["tmp_name"]; } } else { echo "Invalid file"; } ?> Quote Link to comment 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.