perezf Posted September 5, 2006 Share Posted September 5, 2006 I just finished making this script from scratch, i am a beginner in php and was wondering how i can set my file uploader to only upload images and also not to upload the image if the file already exist?[quote]<div align="center"><h1>Picture Easy Uploader</h1><?phpif(isset($_POST['Submit'])){if ($_FILES[image] != '') { @copy($_FILES[image][tmp_name], "uploads/".$_FILES[image][name]) or die("Couldn't copy the file."); echo "The file upload was a success, click on the link to see it. <a href=\"uploads/".$_FILES[image][name]."\">Click Here</a><br />"; echo "The Myspace code is as follows<br /><b><img src=\"http://2fr3sh.com/scripts/uploads/".$_FILES[image][name]."\" /></b> <br />"; echo "A preview is below<br /><a href=\"uploads/".$_FILES[image][name]."\"><img src=\"http://2fr3sh.com/scripts/uploads/".$_FILES[image][name]."\" width=\"150\" /></a>";} else { die("No Input File Specified");}} else{?><form action="" method="post" enctype="multipart/form-data" name="form1"> <input type="file" name="image"> <br> <input type="submit" name="Submit" value="Upload Your File"></form><?php }$dir_name = "uploads/";$dir = opendir($dir_name);$file_list = "<ol>";while ($file_name = readdir($dir)){if (($file_name != ".") && ($file_name != "..")) { $file_list .= "<li><a href=\"uploads/".$file_name."\">".$file_name; echo "</a>"; } } $file_list .= "</ol>";echo "<div align=\"left\">";echo "The files currently uploaded are as follows:<br />".$file_list;echo "</div>";?></div> [/quote] :) Link to comment https://forums.phpfreaks.com/topic/19720-i-need-help-with-easy-php/ Share on other sites More sharing options...
perezf Posted September 5, 2006 Author Share Posted September 5, 2006 i only also want it to read the image files and nothing else Link to comment https://forums.phpfreaks.com/topic/19720-i-need-help-with-easy-php/#findComment-86095 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.