Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Upload Pics With Php?
leiaah
post May 12 2005, 12:59 AM
Post #1


Super Member
*********

Group: Members
Posts: 436
Joined: 21-January 05
From: Koronadal City, Philippines
Member No.: 3,358



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)
Go to the top of the page
 
+Quote Post
mizako
post May 12 2005, 07:44 AM
Post #2


Super Member
*********

Group: Members
Posts: 372
Joined: 16-August 04
From: Spain
Member No.: 824



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!!!!
Go to the top of the page
 
+Quote Post
HmmZ
post May 12 2005, 09:49 AM
Post #3


Super Member
*********

Group: Members
Posts: 362
Joined: 2-March 05
From: The Netherlands
Member No.: 4,097



also here, GOOGLE is your friend...

Search term: image upload php code

http://codewalkers.com/seecode/85.html
http://php.resourceindex.com/Complete_Scri...ile_Management/
http://www.fuzzywebmaster.com/results/php-...ipt-upload.html
http://www.stadtaus.com/en/php_scripts/gallery_script/
Go to the top of the page
 
+Quote Post
icey
post May 17 2005, 07:10 PM
Post #4


Newbie [Level 2]
**

Group: Members
Posts: 33
Joined: 19-February 05
From: SLOVENIA
Member No.: 3,855



yes google is still useful biggrin.gif
Go to the top of the page
 
+Quote Post
leiaah
post May 17 2005, 11:05 PM
Post #5


Super Member
*********

Group: Members
Posts: 436
Joined: 21-January 05
From: Koronadal City, Philippines
Member No.: 3,358



Great. I'm toying with the code alrady. Thanks!
Go to the top of the page
 
+Quote Post
alexia
post May 21 2005, 09:17 AM
Post #6


Super Member
*********

Group: Members
Posts: 310
Joined: 9-February 05
From: Italian
Member No.: 3,677



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
Go to the top of the page
 
+Quote Post
Bayuugan
post Jun 8 2008, 02:40 PM
Post #7


Newbie [Level 3]
***

Group: Members
Posts: 49
Joined: 28-May 08
Member No.: 62,777



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
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Share Your Pics Of Your Pets.(4)
  2. Php Ftp Upload Form(1)
  3. Cms/upload Best Practice?(9)
  4. Upload Via Url..plz Help(0)
  5. Post Dem Pics(0)
  6. The New And Very Good Free Host Server(13)
  7. Anywhere Fm(0)
  8. Auto-upload Files With Filezilla And Autohotkey(0)
  9. Increase Upload Limit(5)
  10. Test Your Php Pages W/o Upload/internet(57)
  11. Image Upload(11)
  12. Photoshop Cs Tutorial - Make Your Pics A Little Spooky(5)
  13. Mylot.com(16)
  14. Where Do I Upload My Ftp Files? [resolved](1)
  15. Why Can't I Upload Files?(2)
  1. File Upload From Url(3)
  2. Upload Script To Transfer Files From Laptop To Desktop(3)
  3. Test Your Connection Speed(51)
  4. Ftp Trap17 Account Help Please(14)
  5. Please Do Not Upload Adult Images - Accounts Will Be Banned(5)
  6. Batch Upload Script(1)
  7. Http File Upload (post)(4)
  8. File Upload(1)
  9. Some Skateboarding Pics(8)
  10. Text Based Rpg(2)
  11. I.p Download Manager(0)
  12. Need Help Installing Smf(5)
  13. Free iPod! This is real, pics included.(25)
  14. How To Save Upload Time In Cpanel(37)
  15. How Do I Upload A Mssql Database To My Server?(3)