I have issue with a php script i tried to use for file upload (ref: sitepoint 2015)
===index.html========

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>form upload</title> </head> 
<body> 
<form action="control.php" method="post"
enctype="multipart/form-data"> <p><label id="upload">Select file to upload:
<input type="hidden" name="MAX_FILE_SIZE" value="1024"> <input type="file" id="upload" name="upload"></label></p> <p> <input type="hidden" name="action" value="upload"> <input type="submit" value="Submit"> </p> </form> </body> </html>

============END OF Index.html============
Below is the php script

==== control.php============

<?php
// Pick a file extension
if (preg_match('/^image\/p?jpeg$/i', $_FILES['upload']['type']))
{
$ext = '.jpg';
}
else if (preg_match('/^image\/gif$/i', $_FILES['upload']['type']))
{
$ext = '.gif';
}
else if (preg_match('/^image\/(x-)?png$/i',
$_FILES['upload']['type']))
{
$ext = '.png';
}
else
{
$ext = '.unknown';

}

// The complete path/filename

$filename = 'C:/xampp/htdocs/Php_Msql/fileUp/uploads/' . time() . $_SERVER['REMOTE_ADDR'] . $ext;

// Copy the file (if it is deemed safe)
if (!is_uploaded_file($_FILES['upload']['tmp_name']) or
!copy($_FILES['upload']['tmp_name'], $filename))
{
$error = "Could not save file as $filename!";
include $_SERVER['DOCUMENT_ROOT'] . '/Php_Msql/fileUp/includes/error.html.php';
exit();
}

===============END OF Control.php==================

The error message i get for trying different files is below
==>Error<==: Could not save file as C:/xampp/htdocs/Php_Msql/fileUp/uploads/1449047923::1.unknown!

Seems your REMOTE_ADDR is an IPv6 address containing ::1. You cannot use colons in a filename.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.