Jump to content


Photo

i need help with easy php


  • Please log in to reply
1 reply to this topic

#1 perezf

perezf
  • Members
  • PipPipPip
  • Advanced Member
  • 301 posts
  • LocationFort Lauderdale

Posted 05 September 2006 - 12:26 AM

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?

<div align="center"><h1>Picture Easy Uploader</h1><?php
if(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>&lt;img src=\"http://2fr3sh.com/sc...loads/".$_FILES[image][name]."\" /&gt;</b> <br />";
echo "A preview is below<br /><a href=\"uploads/".$_FILES[image][name]."\"><img src=\"http://2fr3sh.com/sc...loads/".$_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>

:)

#2 perezf

perezf
  • Members
  • PipPipPip
  • Advanced Member
  • 301 posts
  • LocationFort Lauderdale

Posted 05 September 2006 - 12:28 AM

i only also want it to read the image files and nothing else




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users