Artificial Intelligence Programs For Programming in Python

Traveling Salesman Problem ( TSP )] Artificial Intelligence Programs For Master Leval Programming in Python from iter tools import permutations def distance(point1, point2): >>> distance([3,4],[0,0]) 5.0 >>> distance([3,6],[10,6]) 7.0 return ((point1[0] - point2[0])**2 + (point1[1] - point2[1])**2) ** 0.5 def total_distance(points): all the points are in the given order. >>> total_distance([[1,2],[4,6]]) 5.0 >>> total_distance([[3,6],[7,6],[12,6]]) 9.0 return sum([distance(point, points[index + 1]) for index, point in enumerate(points[:-1])]) def travelling_salesman(points, start=None): Time complexity is O(N!), so never use on long lists. >>> travelling_salesman([[0,0],[10,0],[6,0]]) ([0, 0], [6, 0], [10, 0]) >>> travelling_salesman([[0,0],[6,0],[2,3],[3,7],[0.5,9],[3,5],[9,1]]) ([0, 0], [6, 0], [9, 1], [2, 3], [3, 5], [3, 7], [0.5, 9]) """ if the start is None: start = points[0] return min([perm for perm ...

How to Multiple files upload at once using PHP - CodingPoint

Multiple files upload at once using PHP
How to Upload Multiple Files in php
Multiple Upload Files

First Create File Index.php in Your Editor

Copy This HTML Code

<!DOCTYPE html>
<html>
<head>
<title>Multiple File Upload</title>
<link rel="stylesheet" type="text/css" href="bootstrap.css">
<style type="text/css">
body{
display: table;
margin: 0 auto;
}
</style>
</head>
<body>
<h1>Multiple File Upload Using PHP</h1>
<form action="" enctype="multipart/form-data" method="post">
<div class="form-group">
<label for='upload'>Add Attachments:</label>
<input id='upload' name="upload[]" type="file" multiple="multiple" />
</div>
<p><input type="submit" name="submit" value="Submit" class="btn btn-success"></p>
</form>
</body>
</html>

PHP Code: 

<?php
if(isset($_POST['submit'])){
if(count($_FILES['upload']['name']) > 0){
//Loop through each file
for($i=0; $i<count($_FILES['upload']['name']); $i++) {
//Get the temp file path
$tmpFilePath = $_FILES['upload']['tmp_name'][$i];


//Make sure we have a filepath
if($tmpFilePath != ""){

//save the filename
$shortname = $_FILES['upload']['name'][$i];


//save the url and the file
$filePath = "uploaded/" . date('d-m-Y-H-i-s').'-'.$_FILES['upload']['name'][$i];


//Upload the file into the temp dir
if(move_uploaded_file($tmpFilePath, $filePath)) {


$files[] = $shortname;
//insert into db
//use $shortname for the filename
//use $filePath for the relative url to the file


}
}
}
}


//show success message
echo "<h1>Uploaded:</h1>";
if(is_array($files)){
echo "<ul>";
foreach($files as $file){
echo "<li>$file</li>";
}
echo "</ul>";
}
}
?>

Comments

Post a Comment

Popular posts from this blog

MongoDB Exercises Practice Solution Exercise First

How to Generate QR Code in PHP with jquery Learn Now

How to create Pagination with PHP and MySql - Codingpoint