Jul 23, 2008

Upload Pics With Php?

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > PHP Programming

free web hosting

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.
Confirm Code:

Similar Topics

Keywords : upload, pics, php

  1. Increase Upload Limit
    (5)
  2. Image Upload
    ?!? (11)
    I need the image upload script which automatically resized the image by specified size and store it
    in the specified folder.....
  3. Php Ftp Upload Form
    Adding User Directory to PHP Upload Form - Help (0)
    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....
  4. Share Your Pics Of Your Pets.
    Warning, may be many pics so if your on a slow connection it migth tak (1)
    I personally own MANY pets and my GF and I have a thing for taking pictures of them (They usually
    either look cool, funny or cute so its a no brainer that a camera appears) here are a few shots of
    my fish: I got rather excited the other day because my plecostomus (who is named Pelco) decided to
    strike a pose on the side of the tank so I quickly grabbed my GF's camera and started taking
    pictures. This is probably the best photo I have taken of him, he just sat there and allowed me to
    take it so I got really lucky. Here are more angles: Also here are a few....
  5. Where Do I Upload My Ftp Files? [resolved]
    As in, which directory? (1)
    I recently got approved for hosting. I have an account right now, but I don't know which
    directory to post my FTP stuff in. (I don't know if this is in support or not; the search
    results didn't return anything.) I remember with my last host that had CPanel that you had to
    upload it into the "public_html" folder. So I do that, or do I just upload it into the root
    directory? Thanks in advance! (EDIT: Oh, never mind, it is /public_html.)....
  6. Why Can't I Upload Files?
    When I try to upload files, it says "File uploads are restricted t (2)
    I have a Qupis account otivtech.qupis.com. Now when I try to upload files using the file manager,
    the text above says that "File uploads are restricted to prevent account issues caused by exceeding
    your file system quota". What do I do?....
  7. Please Do Not Upload Adult Images - Accounts Will Be Banned
    Imagefilez TOS re-visited (5)
    Hi Guys, Starting on with Good news first. We have moved Imagefilez.com on a new & more faster
    dedicated server and the site is now loading really fast, so you guys can upload all your images
    /smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> Now some serious
    stuff is that we were spammed some days back, with the upload of adult images in huge numbers from
    some Japanese/Chinese IP's, we have deleted all the images & also banned these IP's. I
    request you all not to upload pornographic images or we will be forced to delete you....
  8. Ftp Trap17 Account Help Please
    cPanel issues and can't upload files (14)
    A few days ago I tried to log into cPanel on my site ( www.liamssite.trap17.com ) and it didnt work.
    Also, whenever I try to upload a file (I use filezilla) I get this: QUOTE Status: Resolving
    IP-Address for liamssite.trap17.com Status: Connecting to 64.69.46.210:21... Status: Connection
    established, waiting for welcome message... Response: 220---------- Welcome to Pure-FTPd ----------
    Response: 220-You are user number 2 of 50 allowed. Response: 220-Local time is now 11:31. Server
    port: 21. Response: 220-This is a private system - No anonymous login Response: 220-....
  9. Photoshop Cs Tutorial - Make Your Pics A Little Spooky
    How to Add ghost in your pics. Let peoples wondering is ir a real ghos (5)
    First, you need source pic. I labelled the source pic as S . Heres my source pic: Look spooky
    isn't it? And here's my original pic. I label my original pic as O. Next, i paste the
    S picture on the O picture using adobe photoshop and erase the undesired area. Adjust the S
    position.. Here's the result: Select the S layer and and adjust the opacity and fill until
    you get the most spooky look. Go to filter and select blur-gaussian blur.. Select smudge tool and
    smudge the S picture until you get a better and real ghost shape. Repeat this step un....
  10. 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.....
  11. 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....
  12. Text Based Rpg
    with some pics (2)
    I am wanting to make a Text based RPG... (not multiplay)... how do you sugest i get started... i
    know some python and a very little bit on vb.. i used realbasic at school.. and thats like vb.. but
    i would rather use python... is python a good choice?....
  13. I.p Download Manager
    changing upload limit (0)
    I recently purchased I.P Download Manager(The download manger that you can purchase from invision
    power services) for my forum. When you go to make categories in the AdminCP, there is a field where
    you can edit the upload limit. This is what it says: QUOTE Maximum screenshot file sizes
    allowed (in kB) Your host has limited the maximum file upload size to 2M. You cannot set this value
    any higher than the maximum your host has set. Is there anyway I can make the upload limit
    larger than 2mb? I have another downloads manger which is unrelated to the forum, on this....
  14. Need Help Installing Smf
    It's not finding the files I upload. (5)
    I downloaded the zip version of the SMF, from www.simplemachines.org I am using SmartFTP, to upload
    the files. I created a folder, named Forum, and uploaded all the SMF files there. On the
    simplemachines site, it tells me to type my site url followed by /forum/install.php, or whatever the
    directory I installed it on is called. I tried that, and I come up with this on the page. Not
    Found The requested URL /forum/smf1.1/install.php was not found on this server. Additionally, a 404
    Not Found error was encountered while trying to use an ErrorDocument to handle the re....
  15. Mylot.com
    earn a lot of money on discussion and upload image (16)
    The site is mylot and all you have to do is stay active in the site by creating or responding to
    discussions and upload photos. You get 1 cents minimum for each response you post or when someone
    responds to your topic. Your rating in the site goes up by 1 for each unique discussion you take
    part in or when someone responds to the discussions started by you for the first time. They pay you
    based on the quality of the posts you make. so, if you really make a worthy reply, you can expect
    5-10 cents for a reply. Respond to as many discussions as possible and earn. You ca....
  16. How Do I Upload A Mssql Database To My Server?
    (3)
    I have a windows based account and would like to know how to upload my database to the server.
    Where do I find the path where the databases reside? Also, is there any documentation that is
    available? Thanks.....
  17. Can't Upload .htaccess And .mdu File...
    bad filenames (5)
    Hi there i am new to computing host free web hosting.. and I try to upload a php script file.. all
    the .php file was uploaded but the .htaccess and .mdu file was not. it has an error and the error
    says this: bad filenames extension.. what should i do? pls. help!! thanks a lot.....
  18. Upload Script To Transfer Files From Laptop To Desktop
    (3)
    Would it be allowed to have an upload script to transfer text files (homework) from laptop to
    desktop? Because my printer is set up from my desktop, and most of my homework is done on my laptop.
    So would this be allowed? Thanks.....
  19. Your Desktop Area
    Snap some pics and post em' (13)
    Just wanted too see what everybody works at there computers, maybe this would be a fun post to
    start. Maybe we can see what pops up or where people are sitting when theyare view trap17.com
    Anyways, here is my desk, simple but effective. Have my Dell Optiplex, thats old but upgraded to
    Win. XP Pro and works like a charm, and my brand new monitor. Have my gadgets and PhotoShop CS 2
    book, and the Easy Button, the number one stress busting tool. /cool.gif"
    style="vertical-align:middle" emoid="B)" border="0" alt="cool.gif" /> ....
  20. Pictures From My Trip
    joing to tripd idnt it funny.........specialy the pics remind me of th (6)
    her r some pics...of a trip that i presented...LOL............ check this 2....
  21. Free 1gb Hard Drive Ftp, One Of The Best Free Upload Services.
    Just register, and share files with anyone. (8)
    It not only offers you 1 GB free, but you can see after you register (don't need to be activated
    by email adress link) that it is even better then windows xp interface, it has so many cool
    functions that perhaps, in the future, people won't buy hard drives, people will buy virtual
    hard drives like this one. I won't say so more, just see for yourself, it is amazing the
    features it is offering for free, just discover for yourself like i did, it's easy and fun. I
    uploaded some files there to show you that we can, in fact, share the files we upload: http:/....
  22. Http File Upload (post)
    (4)
    Does anyone know how to upload a file and form data to a server? What i want to do is allow a user
    to upload a file and form data to my php script so i can process it. So of course FTP would be no
    good. I can do this with the XMLHTTP control but it does not thread and it pretty lame. Surely you
    can do it with winsock or Inet Any ideas? Source code would be greatly appreciated. ....
  23. Upload Component - Failed
    Problem with Mambo (5)
    Hello! When I am trying to upload a component in joomla (I upgraded from mambo, I had the same
    problem on mambo), it dont work, i get this error message: ! Upload component - Failed" "File
    /home/esector/public_html/Gamesector/media/install_4381d76108f20/com_forum.zip does not exist!
    " How can I fix it?....
  24. Google Base
    New Google gadget - you upload thru them (7)
    Google Base is a place where you can add all types of information that Google will host and make
    searchable online. You can describe any item you post with attributes, which will help people find
    it when they search Google Base. In fact, based on the relevance of your items, they may also be
    included in the main Google search index and other Google products like Froogle and Google Local.
    http://base.google.com/base/default?gsessionid=n1rDrGjOPMU This looks like it is in beta and was
    just recently announced. In a nutshell, it strikes me as a fascinating but fla....
  25. Some Skateboarding Pics
    Please take a look. (8)
    Heres a link to a few skateboarding pics i did a while back. well a week or something. its my frist
    try at sequences and i did it with my new Canon Digital Rebel Xt, Soo proud of it. haha.
    http://lucs-pics.blogspot.com/2005/08/rollbunker.html so please tell me what you think of them.....
  26. Test Your Connection Speed
    Download and upload speed test (51)
    Ok here goes... I'm a little curious about your internet speed, as you know broadband getting
    trends now after P2P blast and online gaming popularity. I myself sign up for 2000Kbps (about 2Mbps)
    package with upload speed upto 256Kbps. Well, at least that is as the ISP advertised, the question
    is; is that true? am is my connection speed as same as advertised? Okay, for instance, go to
    http://www.testmy.net for testing your download and upload speed. After take both test, post the
    results here ^^ QUOTE :::.. Download Stats ..::: Connection is:: 45216 Kbps about ....
  27. How To Save Upload Time In Cpanel
    (37)
    Do not Extract files and then upload them by ftp, try the following (1)open the file manager
    (2)upload the zip or gz format file (3)then extract the file it save the comulation time for
    ftp client and the ftp server.....
  28. Test Your Php Pages W/o Upload/internet
    complete *working* guide on how to test your php pages (57)
    In this tutorial, I'm going to show you how to test your PHP pages without the Internet or
    uploading the files to your trap17 server. This tutorial is similar to doom's, but the links he
    provided does not work, so I decided to make my own tutorial with working links. The program that I
    will be using for this tutorial is called XAMPP . XAMPP is a modification of the popular Apache
    server, and I'm using XAMPP because of its simplicity to install as well as maintain. The
    current version of XAMPP is 1.4.13 and it has the following bundled in the download: QUOT....
  29. File Upload From Url
    (3)
    i need some help with a file upload script. i have it so i can upload files from my computer, but i
    need one that can upload a file to my server from a url. does anybody know how to do this???....
  30. Free iPod! This is real, pics included.
    I am getting mine! (25)
    To get your free Ipod 1.) Click here to sign up! Then click Next. 2.) Enter your shipping
    address and info then click next. 3.) Just click "No Thanks" to all of mini-offers until you get a
    page to send referrals. 4.) Click skip(You can go back later becouse this takes a while) 5.) Then
    when you get to the offers page go down and click the ebay offer becouse all of the other require a
    credit card(required) 6.) Click register for a new ebay account and follow the steps. 7.) When you
    get to the page where you need to enter a credit card, click use email instead and ....

    1. Looking for upload, pics, php

Searching Video's for upload, pics, php
Similar
Increase
Upload Limit
Image Upload
- ?!?
Php Ftp
Upload Form
- Adding
User
Directory to
PHP Upload
Form - Help
Share Your
Pics Of Your
Pets. -
Warning, may
be many pics
so if your
on a slow
connection
it migth tak
Where Do I
Upload My
Ftp Files?
[resolved] -
As in, which
directory?
Why
Can't I
Upload
Files? -
When I try
to upload
files, it
says
"File
uploads are
restricted t
Please Do
Not Upload
Adult Images
- Accounts
Will Be
Banned -
Imagefilez
TOS
re-visited
Ftp Trap17
Account Help
Please -
cPanel
issues and
can't
upload files
Photoshop Cs
Tutorial -
Make Your
Pics A
Little
Spooky - How
to Add ghost
in your
pics. Let
peoples
wondering is
ir a real
ghos
File Upload
- File
upload
Batch Upload
Script - In
need of
batch upload
script
Text Based
Rpg - with
some pics
I.p Download
Manager -
changing
upload limit
Need Help
Installing
Smf -
It's not
finding the
files I
upload.
Mylot.com -
earn a lot
of money on
discussion
and upload
image
How Do I
Upload A
Mssql
Database To
My Server?
Can't
Upload
.htaccess
And .mdu
File... -
bad
filenames
Upload
Script To
Transfer
Files From
Laptop To
Desktop
Your Desktop
Area - Snap
some pics
and post
em'
Pictures
From My Trip
- joing to
tripd idnt
it
funny.......
..specialy
the pics
remind me of
th
Free 1gb
Hard Drive
Ftp, One Of
The Best
Free Upload
Services. -
Just
register,
and share
files with
anyone.
Http File
Upload
(post)
Upload
Component -
Failed -
Problem with
Mambo
Google Base
- New Google
gadget - you
upload thru
them
Some
Skateboardin
g Pics -
Please take
a look.
Test Your
Connection
Speed -
Download and
upload speed
test
How To Save
Upload Time
In Cpanel
Test Your
Php Pages
W/o
Upload/inter
net -
complete
*working*
guide on how
to test your
php pages
File Upload
From Url
Free
iPod!
This is
real, pics
included. -
I am getting
mine!
advertisement



Upload Pics With Php?



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
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