Current location: Hot Scripts Forums » Programming Languages » PHP » File uploading. Quick question!


File uploading. Quick question!

Reply
  #1 (permalink)  
Old 08-24-07, 12:51 PM
staticfire's Avatar
staticfire staticfire is offline
Wannabe Coder
 
Join Date: May 2007
Location: Stockton, England
Posts: 223
Thanks: 0
Thanked 1 Time in 1 Post
Question File uploading. Quick question!

Recently i added a file manager script to allow my members to host things on my site rather than linking to them from another site. This is my first ever time doing file uploading in PHP and i am having trouble with uploading certain file types. I have implemented the most common image types into it but i have no idea how i would be able to anything except images. I searched all over the web for file uploading examples but they only seem to demonstrate how to set a type as an image. The other types of files i'm allowing people to upload are:

.7z .gm6 .gm7z .gmd .gmk .gml .pdf .rar .swf .txt .zip

Any links or examples would be appreciated.
Thanks
__________________
Visit http://www.staticfire.co.uk
Reply With Quote
  #2 (permalink)  
Old 08-24-07, 02:05 PM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
I don't actually get it! PHP has no special way of handling images. It's global. If you can upload images, you can upload anything else.

can you elaborate more on what you want to do and what exactly is it that you are having problem with?
Also you could look at my upload script which handles any type configured:
http://www.phpsimplicity.com/scripts.php?id=3
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Reply With Quote
  #3 (permalink)  
Old 08-24-07, 03:05 PM
staticfire's Avatar
staticfire staticfire is offline
Wannabe Coder
 
Join Date: May 2007
Location: Stockton, England
Posts: 223
Thanks: 0
Thanked 1 Time in 1 Post
well i currently have the types set at things like.. image/png and image/bmp so i just assumed that it would be something like file/zip to upload a zip. So what you are saying is that i could just put .png and that would work?

So from your script i could have...

$allowed['package'][] = 'swf';
$allowed['package'][] = 'gmk';
$allowed['package'][] = 'gmd';

and then those files would upload?
__________________
Visit http://www.staticfire.co.uk

Last edited by staticfire; 08-24-07 at 03:25 PM.
Reply With Quote
  #4 (permalink)  
Old 08-24-07, 03:29 PM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
Maybe you mean something like this?

http://www.programmingtalk.com/showthread.php?t=29567

But one thing, do not rely on the value in $_FILES['x']['type']. This value is defined by the browser, and can be modified. Plus, some browsers (specially when IE is involved) send different types. Validate the files by extension, and images for example using getimagesize().

If you have the fileinfo library installed and working, then use this instead.
Reply With Quote
  #5 (permalink)  
Old 08-24-07, 05:47 PM
staticfire's Avatar
staticfire staticfire is offline
Wannabe Coder
 
Join Date: May 2007
Location: Stockton, England
Posts: 223
Thanks: 0
Thanked 1 Time in 1 Post
Yeh that's exactly what i meant. Sorry i didn't seem very clear. End users list on that threed is very helpful but now you are suggesting that i don't use $_FILES['x']['type']; i will have to tweak my script a bit. Anyway thanks to both of you for helping me get my head around that
__________________
Visit http://www.staticfire.co.uk
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Your File is uploading Popup scott2500uk JavaScript 6 03-20-07 05:36 PM
Uploading file Deansatch PHP 10 07-24-06 10:33 AM
Quick VB help question: how do you edit a MDB file anonyentry Visual Basic 2 05-28-06 08:37 AM
showing realtime percentage of uploading file tallpaul858 PHP 2 06-01-05 02:04 PM


All times are GMT -5. The time now is 06:08 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.