Add to Google

Upload Pics With Php?

free web hosting
Open Discussion > CONTRIBUTE > Computers > Programming Languages > PHP Programming

Upload Pics With Php?

leiaah
Can anyone help me out again? Thanks.

I need a code that has a basic form that allows you to browse for an image file and when the submit button is clicked, that image gets uploaded to a folder in my site (e.g. images/*.jpg)

Reply

mizako
I was looking for the same functionality. If someone knows how can i code to upload files after browsing and also give the functionality to upload zip files und unzip them once they are uploaded. I would be really grateful!!!!

Reply

icey
yes google is still useful biggrin.gif

Reply

leiaah
Great. I'm toying with the code alrady. Thanks!

Reply

alexia
Oh
i think you can use php script on your cpanel or
search in hotscripts.com or many php scripts web site
but i find to u one uploader CMS
i think find it in scriptsbalabala.com
its very old blink.gif

CODE
<?
$extlimit = "yes"; //Do you want to limit the extensions of files uploaded
$limitedext = array(".gif",".jpg",".png",".jpeg"); //Extensions you want files uploaded limited to.
$sizelimit = "no"; //Do you want a size limit, yes or no?
$sizebytes = "200000"; //size limit in bytes
$dl = "http://www.zachwhite.com/demo/up-down"; //url where files are uploaded
$absolute_path = "/home/zachwhit/public_html/demo/up-down"; //Absolute path to where files are uploaded
$websiteurl = "http://www.zachwhite.com"; //Url to you website
$websitename = "Zach White Network";

switch($action) {
default:
echo"
<html>
<head>
<title>Upload Or Download</title>
</head>
<body>
<a href=$PHP_SELF?action=upload>Upload File</a>
<a href=$PHP_SELF?action=download>Download File</a>
<a href=$websiteurl>Return to $websitename</a>
<br><br>
Powered by <a href=http://www.zachwhite.com/>PHP Uploader Downloader</a>
</body>
</html>";
break;
case "download":
echo "
<html>
<head>
<title>File Download</title>
</head>
<body><a href=$PHP_SELF?action=upload>Upload File</a> <a href=$websiteurl>Return to $websitename</a>";
$list = "<table width=700 border=1 bordercolor=#000000 style=\"border-collapse: collapse\">";
$list .= "<tr><td width=700><center><b>Click To Download</b></center></td></tr>";
$dir = opendir($absolute_path);
while($file = readdir($dir)) {
if (($file != "..") and ($file != ".")) {
//Download files with spaces fix by Kokesh
$list .= "<tr><td width=700><a href='$dl/$file'>$file</a></center></td></tr>";
}
}
$list .= "</table>";
echo $list;
echo"
<br><br>
Powered by <a href=http://www.zachwhite.com/>PHP Uploader Downloader</a>
</body>
</html>";
break;

case "upload":
echo"
<html>

<head>
<title>File Upload</title>
</head>

<body>

<form method=POST action=$PHP_SELF?action=doupload enctype=multipart/form-data>
<p>File to upload:<br>
<input type=file name=file size=30>
<p><button name=submit type=submit>
Upload
</button>
</form>
<br><br>
Powered by <a href=http://www.zachwhite.com/>PHP Uploader Downloader</a>
</body>

</html>";
break;


//File Upload
case "doupload":
$dir = "dir";
if ($file != "") {

if (file_exists("$absolute_path/$file_name")) {
die("File already exists");
}

if (($sizelimit == "yes") && ($file_size > $sizebytes)) {
die("File is to big. It must be $sizebytes bytes or less.");
}

$ext = strrchr($file_name,'.');
if (($extlimit == "yes") && (!in_array($ext,$limitedext))) {
die("The file you are uploading doesn't have the correct extension.");
}

@copy($file, "$absolute_path/$file_name") or die("The file you are trying to upload couldn't be copied to the server");

} else {
die("Must select file to upload");
}
echo "
<html>
<head>
<title>File Uploaded</title>
</head>
<body>";
echo $file_name." was uploaded";
echo "<br>
<a href=$PHP_SELF?action=upload>Upload Another File</a>
<a href=$PHP_SELF?action=download> Download File</a>
<a href=$websiteurl> Return to $websitename</a><br><br>
Powered by <a href=http://www.zachwhite.com/>PHP Uploader Downloader</a>
</body>
</html>";
break;

}
?>

Save this code on one php file and save name is updown
change your folder permission to 777
If you want to upload or download your file form your folder on your host

 

 

 


Reply

Bayuugan
QUOTE(alexia @ May 21 2005, 05:17 PM) *
Oh
i think you can use php script on your cpanel or
search in hotscripts.com or many php scripts web site
but i find to u one uploader CMS
i think find it in scriptsbalabala.com
its very old blink.gif

CODE
<?
$extlimit = "yes"; //Do you want to limit the extensions of files uploaded
$limitedext = array(".gif",".jpg",".png",".jpeg"); //Extensions you want files uploaded limited to.
$sizelimit = "no"; //Do you want a size limit, yes or no?
$sizebytes = "200000"; //size limit in bytes
$dl = "http://www.zachwhite.com/demo/up-down"; //url where files are uploaded
$absolute_path = "/home/zachwhit/public_html/demo/up-down"; //Absolute path to where files are uploaded
$websiteurl = "http://www.zachwhite.com"; //Url to you website
$websitename = "Zach White Network";

switch($action) {
default:
echo"
<html>
<head>
<title>Upload Or Download</title>
</head>
<body>
<a href=$PHP_SELF?action=upload>Upload File</a>
<a href=$PHP_SELF?action=download>Download File</a>
<a href=$websiteurl>Return to $websitename</a>
<br><br>
Powered by <a href=http://www.zachwhite.com/>PHP Uploader Downloader</a>
</body>
</html>";
break;
case "download":
echo "
<html>
<head>
<title>File Download</title>
</head>
<body><a href=$PHP_SELF?action=upload>Upload File</a> <a href=$websiteurl>Return to $websitename</a>";
$list = "<table width=700 border=1 bordercolor=#000000 style=\"border-collapse: collapse\">";
$list .= "<tr><td width=700><center><b>Click To Download</b></center></td></tr>";
$dir = opendir($absolute_path);
while($file = readdir($dir)) {
if (($file != "..") and ($file != ".")) {
//Download files with spaces fix by Kokesh
$list .= "<tr><td width=700><a href='$dl/$file'>$file</a></center></td></tr>";
}
}
$list .= "</table>";
echo $list;
echo"
<br><br>
Powered by <a href=http://www.zachwhite.com/>PHP Uploader Downloader</a>
</body>
</html>";
break;

case "upload":
echo"
<html>

<head>
<title>File Upload</title>
</head>

<body>

<form method=POST action=$PHP_SELF?action=doupload enctype=multipart/form-data>
<p>File to upload:<br>
<input type=file name=file size=30>
<p><button name=submit type=submit>
Upload
</button>
</form>
<br><br>
Powered by <a href=http://www.zachwhite.com/>PHP Uploader Downloader</a>
</body>

</html>";
break;
//File Upload
case "doupload":
$dir = "dir";
if ($file != "") {

if (file_exists("$absolute_path/$file_name")) {
die("File already exists");
}

if (($sizelimit == "yes") && ($file_size > $sizebytes)) {
die("File is to big. It must be $sizebytes bytes or less.");
}

$ext = strrchr($file_name,'.');
if (($extlimit == "yes") && (!in_array($ext,$limitedext))) {
die("The file you are uploading doesn't have the correct extension.");
}

@copy($file, "$absolute_path/$file_name") or die("The file you are trying to upload couldn't be copied to the server");

} else {
die("Must select file to upload");
}
echo "
<html>
<head>
<title>File Uploaded</title>
</head>
<body>";
echo $file_name." was uploaded";
echo "<br>
<a href=$PHP_SELF?action=upload>Upload Another File</a>
<a href=$PHP_SELF?action=download> Download File</a>
<a href=$websiteurl> Return to $websitename</a><br><br>
Powered by <a href=http://www.zachwhite.com/>PHP Uploader Downloader</a>
</body>
</html>";
break;

}
?>

Save this code on one php file and save name is updown
change your folder permission to 777
If you want to upload or download your file form your folder on your host


google is very very useful biggrin.gif

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Recent Queries:-
  1. www.pics.php - 416.05 hr back. (1)
  2. upload jpg php - 553.42 hr back. (2)
Similar Topics

Keywords : upload pics php

  1. Php Ftp Upload Form - Adding User Directory to PHP Upload Form - Help (1)
    Alright I am trying to have a PHP FTP Upload Form that allows the user to create the directory
    folder for where they want to upload there files to. example: Main Directory: vainsoft.com There
    directory: vainsoft.com/modeling or vainsoft.com/photography But I dont want them to be able to
    upload things into the main directory, only sub-directories, is that possible with this coding that
    I have: //uses $_FILES global array //see manual for older PHP version info //This
    function will be used to get the extension from the filename function get_extension($fi...
  2. Image Upload - ?!? (11)
  3. Batch Upload Script - In need of batch upload script (1)
    I'm in the process of making a photo gallery script. I need ideas on how to make a batch upload
    script. I want the user to be able to upload files to a folder via FTP and then go to the admin
    section of the gallery and add the previously uploaded photos to the MySQL database. I guess what I
    need it to do is find all the files in a specific folder and see if they are already in the
    database, if they aren't in the database - add them. Any help would be appreciated. I figured
    trap17 would be a good place to get help with this /wink.gif" style="vertical-align:middle...
  4. File Upload - File upload (1)
    I need to add a facility on my customer's website so his clients can send him jobs, typically
    5mb - 50mb. I've looked around the web and researched this, and tried a few tests (failed), but
    my brain's beginning to hurt. Could someone please tell me the best way to go about this,
    please. The site is done in Flash, but I'm sure a link to an html page would be ok if necessary....
  5. Wappyftp V1.00 - upload to server via ftp from your mobile phone :-) (8)
    wappyFTP v1.00 by wappy --- site: http://cult.trap17.com mail: admin@cult.trap17.com --- -Welcome
    to wappyFTP, with this wap script your users can upload files directly to their server via FTP from
    a mobile phone! --- -Its extremley easy to install, open index.php and put the name of your site
    instead of YOURSITE.COM -Upload the folder wappyFTP_v1.00 to the root directory of your web server
    -Link to it like wappyFTP_v1.00/index.php -Its all done ENJOY --- YOU MAY DISTRIBUTE AND/OR EDIT
    THIS SCRIPT BUT DO NOT REMOVE THE AUTHORS NAME! --- ©2006-2007 wappyCULT /...
  6. Image Upload And File Size - (2)
    Hi, I'm trying to upload rather large jpgs files (2560x1920 and ~ 2 megs in size) to my server
    via PHP. The problem I am having is that when I upload and attempt to resize by creating a new
    image, the new image is always black. Code I'm using is: PHP Code: CODE if(
    !empty($thefile_name) ) {                                                  
                                                 $query = "INSERT INTO coldwell_images
    (imagename) VALUES ('insertimage')";                    $result ...
  7. Alphanumeric Upload Sorting - (0)
    This is what the script does: when a file is uploaded from a form, this script checks what directory
    it should go into. So before the upload occurs, the alphanumeric directories are created ( only
    once, of course). Here it is in code (Please note that this just example code): CODE
    UPLOAD.PHP <?php echo "<form action='upload-sort.php' method='get'
    enctype='multipart/form-data'>"; echo "Upload a file: <input
    type='file' name='upload'>"; echo "</form>"; ?>
    UPLOAD-SO...
  8. upload files - (4)
    upload.php CODE <?php /********************************** * **      file directory list *
    **********************************/ function listthem($add) {   $t=$add;  
    if ($handle = opendir($add))   {      while (($file =
    readdir($handle))!=FALSE)      {        
     $add.="/".$file;          if (is_dir($add)==TRUE)        
     {              if($file!="." && $file!=".." &&
    is_dir($add)=...



Looking for upload, pics, php

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for upload, pics, php

*MORE FROM TRAP17.COM*
advertisement



Upload Pics With Php?



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE