I'm in the process of making a website for my dad that allows people to upload their own personal images because he is a window cleaning tech. He wants to allow people to be able to upload their images so he can give them an estimate on the cost. Below, I have two bits of code. The first bit successfully uploads images. That I won't have to worry about. The second bit, however, does not successfully upload images. What I want to accomplish is that every time a user uploads a set of images (maximum of 5), it will make a new folder in a directory that sets the current time as the name of the folder, that way it will be easier for him to keep track of who sends what. I'm still working out little details on how he can identify a person solely based on images (perhaps a person will call after sending the images in and verify the time of submission?). I am trying to do this with as little use for a database as possible, being I don't know how to use MySQL and tie it to PHP.
This is the code that works and successfully uploads the images to /upload:
<?php
$uploadpath = 'upload/';
$max_size = 4000;
$allowtype = array('bmp', 'gif', 'jpg', 'jpe', 'png');
if(isset($_FILES['fileup']) && strlen($_FILES['fileup']['name']) > 1){
$uploadpath = $uploadpath . basename( $_FILES['fileup']['name']);
$sepext = explode('.', strtolower($_FILES['fileup']['name']));
$type = end($sepext);
list($width, $height) = getimagesize($_FILES['fileup']['tmp_name']);
$err = '';
if(!in_array($type, $allowtype)) $err .= 'The file: <b>'. $_FILES['fileup']['name']. '</b> does not have an allowed extension type.';
if($_FILES['fileup']['size'] > $max_size*1000) $err .= '<br/>Your file exceeds the '. $max_size. ' KB. size limit.';
if($err == ''){
if(move_uploaded_file($_FILES['fileup']['tmp_name'], $uploadpath)){
echo 'File: <b>'. basename( $_FILES['fileup']['name']). '</b> successfully uploaded:';
echo '<br/>File type: <b>'. $_FILES['fileup']['type'] .'</b>';
}
else echo '<b>Unable to upload the file.</b>';
}
else echo $err;
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" enctype="multipart/form-data">
Upload File: <input type="file" name="fileup" /><br/>
Upload File: <input type="file" name="fileup" /><br/>
Upload File: <input type="file" name="fileup" /><br/>
Upload File: <input type="file" name="fileup" /><br/>
Upload File: <input type="file" name="fileup" /><br/>
<input type="submit" name='submit' value="Upload" />
</form>
And here's the code I'm trying to change to make a new folder with the timestamp as the name:
<?php
$uploadpath = 'upload/';
$max_size = 4000;
$allowtype = array('bmp', 'gif', 'jpg', 'jpe', 'png');
if(isset($_FILES['fileup']) && strlen($_FILES['fileup']['name']) > 1){
$uploadpath = $uploadpath . basename( $_FILES['fileup']['name']);
$sepext = explode('.', strtolower($_FILES['fileup']['name']));
$type = end($sepext);
list($width, $height) = getimagesize($_FILES['fileup']['tmp_name']);
$err = '';
if(!in_array($type, $allowtype)) $err .= 'The file: <b>'. $_FILES['fileup']['name']. '</b> does not have an allowed extension type.';
if($_FILES['fileup']['size'] > $max_size*1000) $err .= '<br/>Your file exceeds the '. $max_size. ' KB. size limit.';
if($err == ''){
$uploadpath = "upload/" . time();
$count = 0;
foreach ($_FILES['fileup']['name'] as $filename){
$temp = $_FILES['fileup']['tmp_name'][$count];
move_uploaded_file($temp, $uploadpath . '/' . $filename);
$count++;
}
if(move_uploaded_file($_FILES['fileup']['tmp_name'], $uploadpath)){
echo 'File: <b>'. basename( $_FILES['fileup']['name']). '</b> successfully uploaded:';
echo '<br/>File type: <b>'. $_FILES['fileup']['type'] .'</b>';
}
else echo '<b>Unable to upload the file.</b>';
}
else echo $err;
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" enctype="multipart/form-data">
Upload File: <input type="file" name="fileup" /><br/>
Upload File: <input type="file" name="fileup" /><br/>
Upload File: <input type="file" name="fileup" /><br/>
Upload File: <input type="file" name="fileup" /><br/>
Upload File: <input type="file" name="fileup" /><br/>
<input type="submit" name='submit' value="Upload" />
</form>
the main difference between the two is after the if($err == ''), the second bit of code has one more block here to replace the original "move file" command
I just did something similar for my uncle's company. To solve your issue of not knowing a good way to have the person submit there info you can create a form that takes info and then sends an email to your dad's work email. Here's an example of the php mail function.
$to = 'service#anywhere.com';
$subject = 'New Service Request:';
$time = date('l jS \of F Y h:i:s A');
$body = "New Service Request Submited - $time (time is coming from webserver)\nFirst Name: ".$_POST['fname']."
Last Name:\n ".$_POST['lname']."
Title:\n ".$_POST['title']."
Business:\n ".$_POST['business']."
Phone:\n ".$_POST['phone']."
Email:\n ".$_POST['email']."
Address:\n ".$_POST['address']."
Preferred Method of Contact:\n ".$method."
Equipment Type:\n ".$_POST['type']."
Equipment Issue:\n ".$_POST['issue']."
Additional Comments:\n ".$_POST['comments'];
$headers = 'From: Request Generator <noreply#anything.com>';
mail($to, $subject, $body, $headers);
Email address can be anything you want. Only requirement is that you have a mail server running where your website is (pretty much all hosting companies provide an email server in addition to the webserver). in the header section, you will notice the text in front of . That text shows up as the name of the 'person' who sent the email and the text between the <> is the 'address' it comes from which again doesn't have to be real.
In my body I left the text that generates tickets for my uncle to provide an example of what you may or may not want your tickets to look like.
For your upload error at first glance it looked like you never created the dynamic folder the content is being uploaded into. Try:
mkdir($uploadpath);
before you create or move any files in the directory.
Related
I am trying to upload file using php and i get error of form not submit whenever everything is right according to me below is the code video upload form
<form action="tek.php" method="POST" enctype="multipart/form-data">
<input type="text" name="name" placeholder="Name"><br/>
<input type="text" name="mobile" placeholder="Mobile No."><br/>
<input type="file" name="videouser" ><br/>
<input type="file" name="audiouser" ><br/>
<input type="submit" name="submit" value="Submit">
</form>
and below is my tek.php page code
if(isset($_POST["submit"])){
$name = $_POST["name"];
$mobile = $_POST["mobile"];
$video_dir = "admin/video/";
$temp = explode(".", $_FILES["videouser"]["name"]);
$newfilename = round(microtime(true)) . '.' . end($temp);
move_uploaded_file($_FILES["videouser"]["tmp_name"], "/admin/video/" .$newfilename)or die("not uploading a video");
$videofile = rand() . basename($_FILES["videouser"]["name"]);
if(move_uploaded_file($_FILES["videouser"]["name"], $video_dir.$newfilename))
{
echo "upload video successfull";
}else{
echo "video file not uploaded";
}
$audio_dir = "admin/audio/";
$audiofile = rand() . basename($_FILES["audiouser"]["name"]);
if(move_uploaded_file($_FILES["audiouser"]["name"], $audio_dir.$audiofile) or die("Not Uploaded audio"))
{
echo "upload audio successfull";
}else{
echo "audio file not uploaded";
}
}else{
echo "form not submitted.";
}
above code of tek.php page work fine for image but not for video or audio file i also increase limit post_max_size = 500M and upload_max_size = 500M where i make mistake don't know please help thanks in advance.
Change following codes:
if(move_uploaded_file($_FILES["videouser"]["tmp_name"], $video_dir.$newfilename))
{
echo "upload video successfull";
}else{
echo "video file not uploaded";
}
$audio_dir = "admin/audio/";
$audiofile = rand() . basename($_FILES["audiouser"]["name"]);
if(move_uploaded_file($_FILES["audiouser"]["tmp_name"], $audio_dir.$audiofile) or die("Not Uploaded audio"))
{
echo "upload audio successfull";
}else{
echo "audio file not uploaded";
}
you should use tmp_name instead of name in the move process
Hi Friends i got the answer
1. first configure your php.ini
2. if you use wamp then you get php.ini in wamp/bin/php/php7.0.10(php version)/php.ini
3. set in php.ini
post_max_size = 10240M
upload_max_filesize = 500M
4. Restart Your wamp server(must)
now the code to upload video below in upload.php
<?php
if(isset($_FILES['file'])){
$errors= array();
$file_name = $_FILES['file']['name'];
$file_size =$_FILES['file']['size'];
$file_tmp =$_FILES['file']['tmp_name'];
$file_type =$_FILES['file']['type'];
if (!file_exists('uploaded_here')) { // file will be uploaded in this folder
mkdir('uploaded_here', 0777, true);
}
if(empty($errors)==true){
move_uploaded_file($file_tmp,"uploaded_here/".$file_name);
echo "Uploaded in folder uploaded_here file name is : ".$file_name;
}else{
echo "Not Uploaded";
}
}
?>
<form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']);?>" method="post" enctype="multipart/form-data">
<input type="file" name="file" accept="file_extension|audio/*|video/*|image/*|media_type">
<br>
<input type="submit" value="Upload">
</form>
its working for me
I am trying to upload images from a cell phone and display them on a gallery page. I need each file name to be unique or images will overwrite themselves. I have the following code where $new_image_name is suggested from this topic but I can't seem to get it to work:
if ($_FILES["image"]["error"] > 0) {
//Bad Output for form results red text
echo "<font size = '5'><font color=\"#e31919\">Error: NO CHOSEN FILE <br />";
echo"<p><font size = '5'><font color=\"#e31919\">INSERT TO DATABASE FAILED";
} else {
$new_image_name = 'image_' . date('Y-m-d-H-i-s') . '_' . uniqid() . '.jpg';
move_uploaded_file($_FILES["image"]["tmp_name"],"images/".$new_image_name);
$file="images/".$new_image_name);
$image_title = addslashes($_REQUEST['image_title']);
$sql="INSERT INTO images (name, image, description) VALUES ('','$file','$image_title')";
if (!mysql_query($sql)) {
die('Error: ' . mysql_error());
}
//Good Output for form results green text
echo '
<form enctype="multipart/form-data" action="insert_image.php" method="post" name="changer">
<div style="padding:10px;">
<h2 style="font-size: 28px;">Success!</h2>
<p style="font-size: 18px;">Your file has been successfully uploaded!</p>
</div>
</form>';
}
mysql_close();
This was my code prior to adding uniqid() which worked fine except the images overwrote each other
} else {
move_uploaded_file($_FILES["image"]["tmp_name"],"images/" . $_FILES["image"]["name"]);
$file="images/".$_FILES["image"]["name"];
$image_title = addslashes($_REQUEST['image_title']);
$sql="INSERT INTO images (name, image, description) VALUES ('','$file','$image_title')";
if (!mysql_query($sql)) {
die('Error: ' . mysql_error());
}
//Good Output for form results green text
echo '
<form enctype="multipart/form-data" action="insert_image.php" method="post" name="changer">
<div style="padding:10px;">
<h2 style="font-size: 28px;">Success!</h2>
<p style="font-size: 18px;">Your file has been successfully uploaded!</p>
</div>
</form>';
}
mysql_close();
You should really get into the habit of using error checking. As your code sits right now I can upload ANYTHING and your code will save it as a jpg image.
Start by checking to see if the user even selected a file for upload.
Then compare the file type to a predetermined list of allowed file types.
Then save it as the file type that was uploaded. Which may not always be a jpg. As your code sits right now, if I upload a gif or png file... it will save it as a jpg. Thereby rendering the image useless because it is not a jpg.
Your upload process with error checking...
<?php
$FormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$FormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if(isset($_POST["upload"]) && $_POST["upload"] == 'changer') {
// set some basic variables
$fileName = $_FILES["image"]["name"]; // The file name
$fileTempLoc = $_FILES["image"]["tmp_name"]; // File in the PHP tmp folder
$fileType = $_FILES["image"]["type"]; // The type of file it is
$fileSize = $_FILES["image"]["size"]; // File size in bytes
$fileErrorMsg = $_FILES["image"]["error"]; // 0 for false... and 1 for true
$type = strtolower(substr(strrchr($fileName,"."),1));
if($type == 'jpeg' || $type == 'jpe') { $type = 'jprg'; } // make a jpeg or jpe file a jpg file
if (!$fileTempLoc) { // if no file selected
die ('<div align="center" style="color:#ff0000;"><br /><h3>ERROR: Please select an image before clicking the upload button.<br /><br />Try again</h3></div>');
} else {
// This is the allowed list (images only)
$acceptable = array(
'image/jpeg',
'image/jpg',
'image/jpe',
'image/gif',
'image/png'
);
// check to see if the file being uploaded is in our allowed list
if(!in_array($_FILES['image']['type'], $acceptable) && !empty($_FILES["image"]["type"])) { // Is file type in the allowed list
die ('<div align="center" style="color:#ff0000;"><br /><h3>Invalid file type. Only JPEG, JPG, JPE, GIF and PNG types are allowed.<br /><br />Try again</h3></div>');
} else {
if ($_FILES["image"]["error"] > 0) {
//Bad Output for form results red text
echo "<font size = '5'><font color=\"#e31919\">Error: NO CHOSEN FILE <br />";
echo"<p><font size = '5'><font color=\"#e31919\">INSERT TO DATABASE FAILED";
} else {
$new_image_name = 'image_' . date('Y-m-d-H-i-s') . '_' . uniqid() . '.'.$type;
move_uploaded_file($_FILES["image"]["tmp_name"],"images/".$new_image_name);
$file="images/".$new_image_name;
$image_title = addslashes($_REQUEST['image_title']);
$sql="INSERT INTO images (name, image, description) VALUES ('','$file','$image_title')";
if (!mysql_query($sql)) {
die('Error: ' . mysql_error());
}
//Good Output for form results green text
echo '
<div style="padding:10px;">
<h2 style="font-size: 28px;">Success!</h2>
<p style="font-size: 18px;">Your file has been successfully uploaded!</p>
</div>';
mysql_close();
} // end if no errors
} // end if in allowed list
} // end if no file selected
} // end if form submitted
?>
The form...
<form enctype="multipart/form-data" action="<?php echo $FormAction ?>" method="post" name="changer">
<input type="file" name="image" id="image" />
<input name="submit" type="submit" value="Upload">
<input type="hidden" name="upload" id="upload" value="changer" />
</form>
One final note... Do yourself a favor and stop using mysql. Start using pdo_mysql instead. mysql was deprecated in PHP version 5.5 and totally removed in PHP version 7. If you're using mysql code, your code will soon stop functioning completely.
I am assuming your posted working code, then maybe because of bellow line,
$file="images/".$new_image_name);
You added extra ')' remove that line, it may work fine.
$file="images/".$new_image_name;
Let me know issue is resolved.
I have created a basic car sales website. I have used the following PHP code to upload my image
$target_folder = "Cars_Photos/";
$target_path = $target_folder . basename( $_FILES['fileToUpload']['name'] );
//echo $target_path . '<br><br><br>';
//print_r($_FILES);
print($_FILES['fileToUpload']['tmp_name']);
if(move_uploaded_file($_FILES['fileToUpload']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
?>
So the file is being uploaded to the server and that is great (took me ages to get it to work), I am using phpliteadmin as my database manager and I have a field called car_image_url, this is where i paste the url to the image on the server, however I have added a page on the site where users can upload an image themselves, so my question is how can I get this to work.
I am using the following to convert the url to display an image.
echo "<td id='img'><img src=\"". $row["car_image_url"] . "\" /></td>";
However uploading the file is a different story, what code do I use on my website to get the uploaded file to link to the image url.
Here is my PHP code that makes a new car on the main site:
<?php
try {
# Connect to SQLite database
$dbh = new PDO("sqlite:../Car_Sales_Network");
$make = $_POST['Make'];
$model = $_POST['Model'];
$badge = $_POST['Badge'];
$price = $_POST['Price'];
$trans = $_POST['Transmission'];
$ppl = $_POST['P_Plate_Legal'];
$sth = $dbh->prepare('INSERT INTO Cars_On_Network
("car_make","car_model","car_badge","price","trans","P_Plate_Legal")
VALUES
(?, ?, ?, ?, ?, ?)');
$sth->execute(array($make, $model, $badge, $price, $trans, $ppl));
$id = $dbh->lastInsertId();
//header("Location: ../Carsales_Network.php");
}
catch(PDOException $e) {
echo $e->getMessage();
}
$target_folder = "Cars_Photos/";
$target_path = $target_folder . basename( $_FILES['fileToUpload']['name'] );
//echo $target_path . '<br><br><br>';
//print_r($_FILES);
print($_FILES['fileToUpload']['tmp_name']);
if(move_uploaded_file($_FILES['fileToUpload']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
?>
Here is the HTML:
<!DOCTYPE html>
<html>
<head>
<title>New Vehicle</title>
<link type="text/css" rel="stylesheet" href="New_Car_Form.css"/>
</head>
<body>
<div id="main">
<form action="Insert_Car.php" method="post" enctype="multipart/form-data">
Make:<br>
<input type="text" name="Make">
<br>
Model:<br>
<input type="text" name="Model">
<br><br>
Badge:<br>
<input type="text" name="Badge">
<br>
Price:<br>
<input type="text" name="Price">
<br>
Transmission: <br>
<input type="radio" name="Transmission" value="Manual" checked>Manual
<br>
<input type="radio" name="Transmission" value="Auto">Automatic
<br><br>
P Plate Legal: <br>
<select name="P_Plate_Legal">
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
<br>
Choose a Picture: <br>
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value="Upload Image" name="submit">
</form>
<br>
<br>
<input class="submit" type="submit" value="Submit">
<br>
Let's go back!
<br>
</div>
</body>
</html>
</form>
</body>
</html>
I am sure it is a similar process however I just can't think of how to do it.
Cheers.
it seems to me like youre having trouble with the upload script.
Here is a way that comes in handy (It creates an unique name for all images)
Crate your sql within the WRITE TO DATABASE comment i made:
if(isset($_FILES['fileToUpload'])){
$File = $_FILES['fileToUpload'];
//File properties:
$FileName = $File['name'];
$TmpLocation = $File['tmp_name'];
$FileSize = $File['size'];
$FileError = $File['error'];
//Figure out what kind of file this is:
$FileExt = explode('.', $FileName);
$FileExt = strtolower(end($FileExt));
//Allowed files:
$Allowed = array('jpg', 'png', 'jpeg', 'gif');
//Check if file is allowed:
if(in_array($FileExt, $Allowed)){
//Does it return an error?
if($FileError==0){
//Create new filename:
$NewName = uniqid('', true) . '.' . $FileExt;
//Destination
$UploadDestination = $_SERVER['DOCUMENT_ROOT'] . '/Cars_Photos/' . $NewName;
//Move file to location:
if(move_uploaded_file($TmpLocation, $UploadDestination)){
//Filename = $NewName
//WRITE TO DATABASE:
//encode url:
$Image = urlencode($UploadDestination);
//Redirect:
header("Location: /complete.php?image=$Image&cat=Cars");
}
//File didnt upload:
else{
echo "File didnt upload...";
}
}
//An error occured
else{
echo "An error occured while uploading...";
}
}
//Filetype not allowed
else{
echo "Sorry, the file you tried to upload is not allowed.";
}
}
Complete.php:
<?php
//Your file is here:
echo urldecode($_GET['image']);
I'm having problems with a file upload script for my site. I've copied a simple upload script, and I'm setting it up so that I can upload multiple files. I have to do this by first making one form for one file, then a copy of the form for the next one and so one. (I first set the page up with the "multiple" tag in the form, but then i discovered that the IE at work is version 8, and no flash. So I have to do it this way)
The scripts uploads ok. The problem is that the second file is called file1.jpgfile2.jpg, the third one file1.jpgfile2.jpgfile3.jpg and so on.
this is my form, followed by the code with form #2 File #2 and on goes through the same form:
<form method="post" enctype="multipart/form-data" action="rediger.php?choice=addpicturetoproc">
<input type="hidden" name="uploadpath" value="<? echo "Prosedyrer/$hovedkategori/$underkategori/$navn/$mappe_navn/" ?>">
Bildefil: <input type="file" name="fileup" value=""><br>
<input type="submit" name="submit" value="Upload">
</form>
<br>
<?
}
elseif ($choice=="addpicturetoproc")
{
$max_size = 2000; // maximum file size, in KiloBytes
$alwidth = 1900; // maximum allowed width, in pixels
$alheight = 1800; // maximum allowed height, in pixels
$allowtype = array('bmp', 'gif', 'jpg', 'jpe', 'png'); // allowed extensions
if(isset($_FILES['fileup']) && strlen($_FILES['fileup']['name']) > 1) {
$uploadpath = $uploadpath . basename( $_FILES['fileup']['name']); // gets the file name
$sepext = explode('.', strtolower($_FILES['fileup']['name']));
$type = end($sepext); // gets extension
list($width, $height) = getimagesize($_FILES['fileup']['tmp_name']); // gets image width and height
$err = ''; // to store the errors
// Checks if the file has allowed type, size, width and height (for images)
if(!in_array($type, $allowtype)) $err .= 'The file: <b>'. $_FILES['fileup']['name']. '</b> not has the allowed extension type.';
if($_FILES['fileup']['size'] > $max_size*1000) $err .= '<br/>Maximum file size must be: '. $max_size. ' KB.';
if(isset($width) && isset($height) && ($width >= $alwidth || $height >= $alheight)) $err .= '<br/>The maximum Width x Height must be: '. $alwidth. ' x '. $alheight;
// If no errors, upload the image, else, output the errors
if($err == '') {
if(move_uploaded_file($_FILES['fileup']['tmp_name'], $uploadpath)) {
echo '<h1>Filen: <b>'. basename( $_FILES['fileup']['name']). '</b> ble lastet opp!</h1>';
}
else echo '<b>Feil ved opplastning.</b>';
}
else echo $err;
}
?><p>Do you need another upload?</p>
<form method="post" enctype="multipart/form-data" action="rediger.php?choice=addpicturetoproc">
<input type="hidden" name="uploadpath" value="<? echo $uploadpath; ?>">
Bildefil: <input type="file" name="fileup" value="Sett inn bildefilen her"><br>
<input type="submit" name="submit" value="Last opp bildefil">
</form>
<br>
<form method="post" enctype="multipart/form-data" action="rediger.php?choice=menu">
<input type="submit" name="submit" value="Nei, jeg er ferdig">
</form>
I have tried using unset($fileup); before the second run, but still filename1.jpgfilename2.jpg.
Any obvious solutions?
I believe this is because you're appending to the $uploadpath
$uploadpath = $uploadpath . basename( $_FILES['fileup']['name']);
So the first file will be file1.jpg then the second file will be file1.jpgfile2.jpg and so on.
I would suggest setting the base upload path to a different variable and trying something like
$uploadpath = $baseuploadpath . basename( $_FILES['fileup']['name']);
How can I save an image safely from a file input field using PHP & MySQL?
Here is the input file field.
<input type="file" name="pic" id="pic" size="25" />
This is a simple example, it should work.
Although you probably want to add checking for image types, file sizes, etc.
<?php
$image = $_POST['pic'];
//Stores the filename as it was on the client computer.
$imagename = $_FILES['pic']['name'];
//Stores the filetype e.g image/jpeg
$imagetype = $_FILES['pic']['type'];
//Stores any error codes from the upload.
$imageerror = $_FILES['pic']['error'];
//Stores the tempname as it is given by the host when uploaded.
$imagetemp = $_FILES['pic']['tmp_name'];
//The path you wish to upload the image to
$imagePath = "images/";
if(is_uploaded_file($imagetemp)) {
if(move_uploaded_file($imagetemp, $imagePath . $imagename)) {
echo "Sussecfully uploaded your image.";
}
else {
echo "Failed to move your image.";
}
}
else {
echo "Failed to upload your image.";
}
?>
http://php.net/file_upload covers just about everything you need to know.
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$tmpFile = $_FILES['pic']['tmp_name'];
$newFile = '/new_location/to/file/'.$_FILES['pic']['name'];
$result = move_uploaded_file($tmpFile, $newFile);
echo $_FILES['pic']['name'];
if ($result) {
echo ' was uploaded<br />';
} else {
echo ' failed to upload<br />';
}
}
?>
<form action="" enctype="multipart/form-data" method="POST>
<input type="file" name="pic" />
<input type="submit" value="Upload" />
</form>