PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 28th, 2004, 11:13 AM
Ivan477 Ivan477 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Ireland
Posts: 3 Ivan477 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
File download in PHP

hi can anyone lead me in the right direction in regards to users uploading their files(mp3 and jpeg) in PHP, tried loads of tutorials but no results!!! thanks

Reply With Quote
  #2  
Old January 28th, 2004, 11:24 AM
Bruski Bruski is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Toronto, Canada
Posts: 192 Bruski User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
there is a tutorial on this site called blogging from database, are u looking towards just uploading or using information to store the name of the upload into a database?

Reply With Quote
  #3  
Old January 28th, 2004, 11:29 AM
Ivan477 Ivan477 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Ireland
Posts: 3 Ivan477 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thanks, yeah what im aiming for is that the user can upload an MP3 and an image onto the site i'm making, and then the MP3 can be downloaded from the site. finding it really difficult, more complicated then i expected. i'll check out that tutorial anyway, any more info would be appreciated....

Reply With Quote
  #4  
Old January 28th, 2004, 12:17 PM
Bruski Bruski is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Toronto, Canada
Posts: 192 Bruski User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
as soon as my server gets up ill help you out...but basically you will need to chmod your directory where u want to store files or put it in cgi-bin depending on your server

Reply With Quote
  #5  
Old January 28th, 2004, 04:19 PM
Mike_r Mike_r is offline
ExoCrew
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 68 Mike_r User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
There are a lot of pre-made scripts available at hotscripts.com, just download one of them and check the coding ( only if you want to make on on your own ) and learn from it.
__________________
ExoHelpDesk
ExoCrew Free Services

Reply With Quote
  #6  
Old January 28th, 2004, 09:40 PM
Bruski Bruski is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Toronto, Canada
Posts: 192 Bruski User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
ok here we go

PHP Code:
//absolute path/base directory
        
$base_dir="X";
        
        
//imagefile in this case is what has gotten passed through the form
        
$image=$_FILES['imagefile']['name'];
        
        
//this replaces any unwanted spaces with a -
        
$image=str_replace(" ""-"$image);

                
//check if it is the correct file type
                
if ($_FILES['imagefile']['type'] == ("image/gif" || "image/jpeg" || "image/bmp" || "image/jpg")){
                            
//copy the file from the temporary to the base directory
                            
copy ($_FILES['imagefile']['tmp_name'], "$base_dir".$newImage) or die ("Could not copy");
                            
                            
//query the database to input the name of the picture into the database
                            
$query "UPDATE users SET picture='$newImage' WHERE id=$id";      
                            
mysql_query($query);
                            
                } 


this is for images but you can also change it to suit your needs. You can also change the name of the file being input to make sure you dont have duplicates, my advice would be if there is a login to change the name to the users id or name with the file extension so you can quickly follow up on it.

PHP Code:
 $newImage="name" 


that will allow you to change the name to whatever you want. IF there are anymore questions just ask away, this is made for pictures, but like i said you can easily make it for everything

EDIT:

the form would look something like this

PHP Code:
 Filename:
                    <
input type="file\" class=\"picture\" width=170 name=\"imagefile\"> 


and obviously you need form tags around it

Reply With Quote
  #7  
Old January 29th, 2004, 07:09 AM
Gee Gee is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 61 Gee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
I have written some scripts to do exactly what you need. I posted them on this forum ages ago. The scripts allow you to upload files of any kind, the files are then stored in a specified directory, the information about the files are displayed in html tables, the files can be downloaded.

To be able to upload and download files there are scripts that store usernames and passwords for security. Only registered users can upload or download.

Mail me if you want a copy of the scripts and I will find them for you.
__________________
SAFC

Reply With Quote
  #8  
Old January 29th, 2004, 09:04 AM
Bruski Bruski is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Toronto, Canada
Posts: 192 Bruski User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
or just do a search of the forums im sure youll be able to find it

Reply With Quote
  #9  
Old January 29th, 2004, 02:44 PM
Ivan477 Ivan477 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Ireland
Posts: 3 Ivan477 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Cool

Thanks a million for all your help guys

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > File download in PHP


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT