Jump to content


This topic is now archived and is closed to further replies.


i need help with easy php

Recommended Posts

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><?php
if ($_FILES[image] != '') {
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/scripts/uploads/".$_FILES[image][name]."\" /&gt;</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">
  <input type="submit" name="Submit" value="Upload Your File">
<?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] :)

Share this post

Link to post
Share on other sites
i only also want it to read the image files and nothing else

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.