opel Posted September 9, 2007 Share Posted September 9, 2007 I have been working on a file upload script that will allow me to upload word documents, mp3's and PDF's into my site. I have been working on the following script but my validation stataments are causing the upload procedure to fail, any help or advise would be appreciated. <?php require_once('includes/inc_functions.php'); $target = "../files/"; if(isset($_POST['Submit'])) { //reads the name of the file the user submitted for uploading $image=$_FILES['file']['name']; // if it is not empty if ($image) { // get the original name of the file from the clients machine $filename = stripslashes($_FILES['file']['name']); // get the extension of the file in a lower case format $extension = getExtension($filename); $extension = strtolower($extension); // if it is not a known extension, we will suppose it is an error, print an error message //and will not upload the file, otherwise we continue if (($extension != "doc") && ($extension != "jpg") && ($extension != "pdf")) { echo '<h1>Unknown extension!</h1>'; $errors=1; } else { } } //If no errors registred, print the success message and show the thumbnail image created if(isset($_POST['Submit']) && !$errors) { ?> <link href="css/admin.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> function sendImg(img) { opener.document.add.image.value = img; window.close(); } </script> <h1>Thumbnail created Successfully!</h1> <img class="hand" onClick="sendImg('<?= $image_name ?>');" src="<?= $thumb_name ?>" alt="Thumnail"> <? } else { ?> <img src="../People/JunF.jpg" <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> </head> <body> <form name="newad" method="post" enctype="multipart/form-data" action=""> <table width="300" align="center" id="uploadImg"> <tr> <td colspan="2"><h1>Upload Files</h1></td> </tr> <tr> <td colspan="2"> <p align="center" style="font-size:10px;">You can upload files with the <strong>.MP3</strong> extension using this form. Please make sure that all your MP3's have been ID3 tags or they will not display in the flash player.</p></td> </tr> <tr> <td>Please choose a file :</td> <td><input name="file" type="file" /></td> </tr> <tr> <td colspan="2"><div align="center"> <input type="submit" value="Upload File" name="Submit" /> </div></td> </tr> <tr> <td colspan="2"><div align="center"><a href="javascript:window.close()" title="Close Window">Close Window</a></div></td> </tr> </table> </form> </div> </body> </html><? } // end else ?> If you go to this page, http://www.recommendedcosmetics.com/admin/files2.php you will see I am getting an error with unexpected $end. Link to comment https://forums.phpfreaks.com/topic/68566-help-with-file-upload-script/ Share on other sites More sharing options...
trecool999 Posted September 9, 2007 Share Posted September 9, 2007 From what I've heard, you can't repeat the <html></html> even if it's enclosed by if an else. Basically, you're tricking the browser into displaying one HTML page, although there are two in the markup. Link to comment https://forums.phpfreaks.com/topic/68566-help-with-file-upload-script/#findComment-344731 Share on other sites More sharing options...
BlueSkyIS Posted September 9, 2007 Share Posted September 9, 2007 "error with unexpected $end." You are missing a semi-colon or closing bracket somewhere. Link to comment https://forums.phpfreaks.com/topic/68566-help-with-file-upload-script/#findComment-344739 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.