Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old October 22nd, 2007, 03:04 PM
Friend of Wrox
Points: 7,425, Level: 36
Points: 7,425, Level: 36 Points: 7,425, Level: 36 Points: 7,425, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
Posts: 1,524
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default mak upload file secure for public usage

Code:
/* UPLOADING FILE */
$target_path = "../images/gallery/";
$target_path = $target_path . basename( $_FILES['filename']['name']); 

if(move_uploaded_file($_FILES['filename']['tmp_name'], $target_path)) {
      echo "The file ".  basename( $_FILES['filename']['name']). 
        " has been uploaded";
} else {
      echo "There was an error uploading the file, please try again!";
}

$filename = basename( $_FILES['filename']['name']);
Form element:
Code:
<input type="file" name="filename" id="filename" class="textbox" size="40">
I am looking to make my code as secure as possible, it's basically taking a image from the form field and moving it to a directory on the server. I would also like to check what the file type is - as i'm only wanting to allow gif, png, jpg, bmp etc......

I know that the code isn't safe enough to put up live at the moment.......

Cheers,
Picco


www.crmpicco.co.uk
www.ie7.com
__________________
_______________________
Ayrshire Minis - a Mini E-Community
http://www.ayrshireminis.com
http://www.crmpicco.co.uk
Reply With Quote
Reply


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 Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to call a exe file in secure website toshi HTML Code Clinic 0 January 10th, 2008 06:59 AM
public article - public articledetails _keysersoze_ BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 September 8th, 2007 08:38 AM
Filter File Types in ASP.NET File Upload ramuis78 ASP.NET 2.0 Basics 2 May 31st, 2007 10:50 AM
Whole Folder upload(Multi file Upload) ramasamy_rams XML 1 September 9th, 2005 12:43 PM
Pro PHP5, Ch.15, Class file usage BillD Pro PHP 0 April 7th, 2005 11:08 PM



All times are GMT -4. The time now is 12:37 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.