i never really got around to finishing this one but thought someone could use it. it uploads multiple files to the specified directory and allows you to rename the file as well, however, it will NOT check the file type being uploaded so you'd probably want to add that little feature before letting anyone use it publicly.. and it won't check for overwriting either..
By : tapeworm byte
<?php
$maxsize = "200000";
$path = "/full/path/to/my/directory/";
if($uploads <= 1)
{
$uploads = 5;
}
$fields = $uploads + $uploads;
for($n = 0; $n < $uploads; $n++)
{
if($uploadedFile[$n] != "" && $uploadedFile[$n] != "none")
{
copy("$uploadedFile[$n]", "$path$uploadedFile_name[$n]");
rename("$path$uploadedFile_name[$n]", "$path$fileName[$n]");
if(file_exists("$path$fileName[$n]"))
{
print("upload successful for $fileName[$n] - $uploadedFile_size[$n] bytes<br>\n");
}
else
{
print("error: upload failed<br>\n");
}
}
}
print("<form action=\"$PHP_SELF\" method=\"POST\" enctype=\"multipart/form-data\">\n");
print("<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"$maxsize\">\n");
print("<table border=\"0\" cellpadding=\"0\" cellspacing=\"3\"><tr><td>\n");
print("<b>Name:</b></td><td>\n");
print("<b>File Location:</b></td></tr>\n");
for($i = 1; $i <= $uploads; $i++)
{
print("<tr><td><input type=\"text\" name=\"fileName[]\" value=\"example$i.jpg\" size=\"13\"></td><td>\n");
print("<input type=\"file\" name=\"uploadedFile[]\" size=\"25\"></td></tr>\n");
}
print("<tr><td align=\"center\"><input type=\"submit\" value=\"UPLOAD\"></td><td>\n");
print("<a href=\"$PHP_SELF?uploads=$fields\">More Upload Fields</a></td></tr>");
print("</table>\n");
print("</form>\n");
?>
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |
More File Manipulation Code Articles
More By Codewalkers
developerWorks - FREE Tools! |
Rational Modeling Extension for Microsoft .NET enhances usability for code generation supporting a more intelligent refactoring. The latest enhancements enable organizations with Java and .NET systems and software development maintain architectural integrity across heterogeneous platforms. FREE! Go There Now!
|
|
|
|
Attend this launch webcast with Scott Hebner, Vice President of IBM Rational Marketing and Strategy, where he will overview Rational’s new offerings and programs to help customers accelerate software innovation on System z. He will discuss how these solutions help organizations extend their core business processes toward modern architectures such as SOA and web technologies to deliver business improvements that stand the test of time. FREE! Go There Now!
|
|
|
|
Join this Rational Talks to You teleconference, featuring Paul Boustany and Mark Krasovich, to speak to the experts about becoming a Rational ClearCase power user. Get a chance to ask your questions and learn tips and tricks for using Rational ClearCase in Agile development FREE! Go There Now!
|
|
|
|
Visit IBM developerWorks to try the IBM SOA Sandbox for people. The SOA Sandbox for people provides a trial environment with the necessary tooling and components required to enable consistent human and process interaction and collaboration, showing how you can improve user experience and business productivity. FREE! Go There Now!
|
|
|
|
IBM Enterprise Modernization solutions help organizations evolve core IT systems towards modern architectures and technologies—reducing the burden of maintenance and freeing up resources to develop new business requirements and capabilities. With the IBM Enterprise Modernization Sandbox for System z you can evaluate IBM Enterprise Modernization solutions focused on five key areas: Assets, Architectures, Skills, Processes and Infrastructures, and Investment. Each solution is based upon real customer experiences and offers a proven path to get you started with your modernization projects. FREE! Go There Now!
|
|
|
|
This whitepaper provides areas to consider when evaluating any software configuration management solution. It addresses how the IBM solutions (Rational ClearCase and Rational ClearQuest) meet the needs and requirements of both project leaders and developers to provide successful Software Change and Configuration Management. FREE! Go There Now!
|
|
|
|
Visit IBM developerWorks to try the IBM SOA Sandbox for process. The SOA Sandbox for process focuses on providing a trial environment with the necessary tooling and components required to gain a better understanding of business processes and how to best improve existing business processes to derive value quickly. FREE! Go There Now!
|
|
|
|
Build secure Web services with transport-level security using IBM Rational Application Developer V7 and IBM WebSphere Application Server V6.1. Follow this three-part series for step-by-step instructions about how to develop Web services and clients, configure HTTP basic authentication, and configure HTTP over SSL (HTTPS). This first part of the series walks you through building a Web service for a simple calculator application. You generate and test two different types of Web services clients: a Java Platform, Enterprise Edition (Java EE) client and a stand-alone Java client. You also handle user-defined exceptions in Web services. FREE! Go There Now!
|
|
|
|
As organizations integrate software into every aspect of business, they are constantly pressured to deliver faster, better, and cheaper results. Unfortunately, a “dis-integrated” software delivery approach reduces returns while increasing costs. This IBM Rational White Paper shows how Integrated Requirements Management aligns organizations around maximizing value and keeping pace with change. FREE! Go There Now!
|
|
|
|
Download a free trial version of IBM Rational Software Analyzer Developer Edition V7.0 to identify bug defects earlier in the software development cycle. Rational Software Analyzer is an extensible software development solution that reduces the expense of bug-fixes by enabling static analysis code reviews and bug identification very early in the development cycle. FREE! Go There Now!
|
|
|
|
All FREE IBM® developerWorks Tools! |