Jump to content
xisto Community
Sign in to follow this  
leiaah

Upload Pics With Php?

Recommended Posts

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)

Share this post


Link to post
Share on other sites

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!!!!

Share this post


Link to post
Share on other sites

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 :lol:


<?$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://http://ww11.zachwhite.com/demo/up-down&%2334/?gtnjs=1;; //url where files are uploaded$absolute_path = "/home/zachwhit/public_html/demo/up-down"; //Absolute path to where files are uploaded
$websiteurl = "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>
</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://http://ww11.zachwhite.com//?gtnjs=1 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://http://ww11.zachwhite.com//?gtnjs=1 Uploader Downloader</a></body></html>";break;//File Uploadcase "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://http://ww11.zachwhite.com//?gtnjs=1 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


Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.