Current location: Hot Scripts Forums » General Community » Script Requests » Need a good image uploader script and free


Need a good image uploader script and free

Reply
  #1 (permalink)  
Old 02-15-11, 06:10 AM
yosrialgharawy yosrialgharawy is offline
New Member
 
Join Date: Feb 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Need a good image uploader script and free

hi
please i want a very good script " image uploader script"
thankyou very much
Reply With Quote
  #2 (permalink)  
Old 02-16-11, 04:26 AM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
Here is one I designed for someone else a while back.
This program will let you select what type of files you want to allow for upload.
After you have uploaded the file, it will give you one chance to delete the file if you change your mind.
It is fairly easy to customize if you choose to.
PHP Code:

<?php session_start(); ?>
<script>
function selectAll()
{
 var obj = document.getElementsByTagName("input");
 for(var i=0;i<obj.length;i++)
 {
  if(obj[i].type == "checkbox")
  {
   obj[i].checked = "checked";
   }
  }
 }
</script>
<?php
if(!empty($_POST["resetFileTypes"])){unlink("fileTypes.txt");}
if(!empty(
$_POST["fileTyps"]))
{
 
$fp fopen("fileTypes.txt","w");
 foreach(
$_POST AS $value){if($value != "Submit"){fwrite($fp,$value."\r\n");}}
 
fclose($fp);
 }
if(!
file_exists("fileTypes.txt"))
{
 echo 
"<p><strong>Select file types to include.</strong></p>
       <form action='#' method='post'>
        <table border='1'>
         <tr><td><input type='checkbox' name='chkbx1' value='image/pjpeg'>image/pjpeg</td><td><input type='checkbox' name='chkbx2' value='image/jpeg'>image/jpeg</td></tr>
         <tr><td><input type='checkbox' name='chkbx3' value='image/gif'>image/gif</td><td><input type='checkbox' name='chkbx4' value='image/png'>image/png</td></tr>
         <tr><td><input type='checkbox' name='chkbx5' value='text/html'>text/html</td><td><input type='checkbox' name='chkbx6' value='text/plain'>text/plain</td></tr>
         <tr><td><input type='checkbox' name='chkbx7' value='text/xml'>text/xml</td><td><input type='checkbox' name='chkbx8' value='text/css'>text/css</td></tr>
         <tr><td><input type='checkbox' name='chkbx9' value='application/x-php'>application/x-php</td><td><input type='checkbox' name='chkbx10' value='application/javascript'>application/javascript</td></tr>
         <tr><td><input type='checkbox' name='chkbx11' value='application/octet-stream'>application/octet-stream</td><td><input type='checkbox' name='chkbx12' value='application/vnd.ms-excel'>application/vnd.ms-excel</td></tr>
         <tr><td><input type='checkbox' name='chkbx13' value='application/msword'>application/msword</td><td><input type='checkbox' name='chkbx14' value='application/pdf'>application/pdf</td></tr>
         <tr><td><input type='checkbox' name='chkbx15' value='application/msaccess'>application/msaccess</td><td><input type='checkbox' name='chkbx16' value='app/gg'>app/gg</td></tr>
         <tr><td colspan='2'>&nbsp;</td></tr>
         <tr><td><button onclick='selectAll()'>Select all</button><input type='reset' value='Reset'></td><td><input type='submit' name='fileTyps' value='Submit'></td></tr>
        </table>
       </form>"
;
 }
else
{
 
$extensions = array("jpg","JPG","gif","GIF","png","PNG");
 
$msg "";
 
$target_path "images/";
 if(
file_exists("fileTypes.txt"))
 {
  
$fileTypes = array();
  
$fp fopen("fileTypes.txt","r");
  while(!
feof($fp)){$fileTypes[] = trim(fgets($fp));}
  if(empty(
$fileTypes[0]))
  {
   
unlink("fileTypes.txt");
   
header("location:".$_SERVER["PHP_SELF"]);
   }
  }
 
$image "";
 
// Routine to upload and display file. //
 
if(!empty($_POST["upload"]) && !empty($_FILES["uploadedfile"]["size"]))
 {
  if(
in_array($_FILES['uploadedfile']['type'],$fileTypes))
  {
   
$_SESSION["name"] = $_FILES['uploadedfile']['name'];
   
$_SESSION["file"] = $target_path.$_SESSION["name"];
   if(
move_uploaded_file($_FILES['uploadedfile']['tmp_name'],$_SESSION["file"]))
   {
    if(
in_array(substr(basename($_SESSION["file"]),-3),$extensions)){$_SESSION["image"] = "<img src='".$_SESSION["file"]."' width='100' />"."<p><b>".$_SESSION["name"]."</b> has been uploaded successfully.</p>";}
    else{
$_SESSION["image"] = "<p><b>".$_SESSION["name"]."</b> has been uploaded successfully.</p>";}
    
$_SESSION["image"] .= "<form action='#' method='post'><input type='submit' name='delete' value='Delete File' style='float:left;' /><input type='submit' name='ulf' value='Upload another file' style='float:right;' /></form>";
    }
   else{
$msg "There was an error uploading the file, please try again!";}
   }
  else{
$msg "That file is not allowed.";}
  }
 
// Routine to delete file. //
 
if(!empty($_POST["delete"]))
 {
  if(
file_exists($_SESSION["file"]))
  {
   
unlink($_SESSION["file"]);
   
$msg "<b>".$_SESSION["name"]."</b> has been deleted.";
   
$_SESSION["file"] = "";
   
$_SESSION["name"] = "";
   
$_SESSION["image"] = "";
   }
  }
 if(!empty(
$_POST["ulf"]))
 {
  
$_SESSION["file"] = "";
  
$_SESSION["name"] = "";
  
$_SESSION["image"] = "";
  }
?>

 <html>
 <head>
 <title>Upload Your Second Image</title>
 </head>
 <body>
 <?php
 
if(!empty($_SESSION["file"]))
 {
  echo 
"<div style='width: 550px; border: solid #016ea7; margin-right:auto; margin-left:auto;'>
         <div style='background: #016ea7; color: #FFF'><p><strong>File Upload</strong></p></div>
         <div style='margin-bottom:20px;'>"
.$_SESSION["image"]."</div>
        </div>"
;
  }
 else{
?>
 <div style="width: 550px; border: solid #016ea7; margin-right:auto; margin-left:auto;">
 <div style="background: #016ea7; color: #FFF"><p><strong>File Upload</strong></p></div>
 <div><?php echo $msg?></div>
 <form enctype="multipart/form-data" action="#" method="POST">
 <input type="hidden" name="MAX_FILE_SIZE" value="1000000" />
 Choose a file to upload: <input name="uploadedfile" type="file" />
 <p><input type="submit" name="upload" value="Upload File" style="float:left;"/><input type="submit" name="resetFileTypes" value="Reset file types" style="float:right;" /></p>
 </form>
 </div>
 </body>
 </html>
<?php }}?>
__________________
Jerry Broughton
Reply With Quote
  #3 (permalink)  
Old 03-03-11, 05:39 AM
yosrialgharawy yosrialgharawy is offline
New Member
 
Join Date: Feb 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
thankyou too much
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Free themes for scripteen free image hosting script coolsitesv Web Design 0 04-28-10 03:00 PM
Is there a good free script for membership system on my website? roig12 Script Requests 2 07-14-09 10:06 AM
Free Image Host Script Jay-z General Advertisements 0 12-29-06 08:21 AM
Free image hosting script phpfreek Script Requests 1 02-12-06 08:58 AM
Free Image Hosting / Script Sale 4n7hr4x Job Offers & Assistance 9 10-29-04 08:13 PM


All times are GMT -5. The time now is 10:06 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.