etsted
-
Posts
274 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by etsted
-
-
how many kb is there in a video that last for 10 minutes?
- 1
-
my name is etsted, cool
-
-
this is my latest code, and it works, but i also want to add a MAX SIZE limit. I have tried
if($_FILES['file']['size'] < 20 000)
{
my code goes here
}
else
{
echo "you're file is to big";
}
But it did not work.
Also here is my code.
<?php$path = pathinfo($_FILES['file']['tmp_name']);$allowed = array('jpg','jpeg','gif','png','swf','MP4','flv','mgp','mpeg','webm','rm','ram','mov','wmv','avi','MPEG-4');if(!in_array($path['extension'],$allowed)){include "connect.php";$name = $_FILES['file']['name'];$temp = $_FILES['file']['tmp_name'];move_uploaded_file($temp, "upload/".$name);$url = "http://localhost:81/upload/$name";mysqli_query($con, "INSERT INTO videos VALUES('','$name','$url')") or die(mysql_error());mysqli_close($con);}else{echo "må være et bilde";}?><html><body><form action="index.php" method="POST" enctype="multipart/form-data"><input type="file" name="file" /><br /><input type="submit" name="submit" /></form><a href='videos.php'>videos</a><?phpif(isset($_POST['submit'])){echo "<br />".$name." has been uploaded";}?></body></html> -
Just to clarify, the error supressor operator is "@". Remove all the @ and see what error messages show up.
The main problem here is that you're checking name of the temporary file rather on the server. You need to check what name the file had on the client, which is in the $_FILES array.
$path = pathinfo($_FILES['file']['name'])
it worked
-
here is the new code i made, but every time i upload a picture it works, but if i try to upload a video it says: NOTICE undefined variable: name
<?php$allowedExts = array("gif", "jpeg", "jpg", "png","MP4","MPEG-4","mp4");$temp = explode(".", $_FILES["file"]["name"]);$extension = end($temp);if ((($_FILES["file"]["type"] == "image/gif")|| ($_FILES["file"]["type"] == "image/jpeg")|| ($_FILES["file"]["type"] == "image/jpg")|| ($_FILES["file"]["type"] == "image/pjpeg")|| ($_FILES["file"]["type"] == "image/x-png")|| ($_FILES["file"]["type"] == "image/png"))&& ($_FILES["file"]["size"] < 20000)&& in_array($extension, $allowedExts)){include "connect.php";$name = $_FILES['file']['name'];$temp = $_FILES['file']['tmp_name'];move_uploaded_file($temp, "upload/".$name);$url = "http://localhost:81/upload/$name";mysqli_query($con, "INSERT INTO videos VALUES('','$name','$url')") or die(mysql_error());mysqli_close($con);}else{echo "Invalid file";}?><html><body><form action="index.php" method="POST" enctype="multipart/form-data"><input type="file" name="file" /><br /><input type="submit" name="submit" /></form><a href='videos.php'>videos</a><?phpif(isset($_POST['submit'])){echo "<br />".$name." has been uploaded";}?></body></html> -
I have changed everything back to normal. Whit my normal script, but i want to make sure that the user can only upload videos and images. Anyone knows how to fix that? I also want to be able to set a maximum size.
Here is my script:
<?phpinclude "connect.php";$name = $_FILES['file']['name'];$temp = $_FILES['file']['tmp_name'];move_uploaded_file($temp, "upload/".$name);$url = "http://localhost:81/upload/$name";mysqli_query($con, "INSERT INTO videos VALUES('','$name','$url')") or die(mysql_error());mysqli_close($con);?><html><body><form action="index.php" method="POST" enctype="multipart/form-data"><input type="file" name="file" /><br /><input type="submit" name="submit" /></form><a href='videos.php'>videos</a><?phpif(isset($_POST['submit'])){echo "<br />".$name." has been uploaded";}?></body></html> -
-
when i try to upload a video or image, i get this error:
Array ( [file] => Array ( [name] => bill 004.MP4 [type] => video/mp4 [tmp_name] => C:wamptmpphp145C.tmp [error] => 0 => 1472766 ) ) 1Array ( [dirname] => C:wamptmp [basename] => php145C.tmp [extension] => tmp [filename] => php145C ) 1
-
-
-
-
this script keep returning warning mysqli_num_rows expect paramter 1 to be a result boolean given. Why?
<html><body><h1>search engine</h1><form action="search.php" method="get"><input type="text" name="k" size='50' /><input type="submit" name="submit" value='Search' /></form><hr /><?phpinclude "connect.php";$k = $_GET['k'];$terms = explode(".", $k);$query = "SELECT * FROM users WHERE ";foreach($terms as $each) {$i++;if($i == 1) {$query .= "keywords LIKE '%$each%' ";} else {$query .= "OR keywords LIKE '%$each%' ";}}$query = mysqli_query($con, $query);$numrows = mysqli_num_rows($query);if($numrows > 0){while($row = mysqli_fetch_array($query)) {$id = $row['id'];$title = $row['title'];$description = $row['description'];$keywords = $row['keywords'];$link = $row['link'];if($k == "") {echo "";} else {echo "<h2><a href='$link'>$title</a></h2>$description";}}}else{echo "no result on $k";}?></body></html> -
-
i tried to add MP4 SWF and some other video formats, but i doesnt work. what am i doing wrong?
here is my code:
<?php@$path = pathinfo(@$_FILES['file']['tmp_name']);$allowed = array('jpg','jpeg','gif','png','swf','MP4','flv','mgp','mpeg','webm','rm','ram','mov','wmv','avi','MPEG-4');if(in_array(@$path['extension'],$allowed)){include "connect.php";$name = $_FILES['file']['name'];$temp = $_FILES['file']['tmp_name'];move_uploaded_file($temp, "upload/".$name);$url = "http://localhost:81/upload/$name";mysql_query("INSERT INTO videos VALUES('','$name','$url')") or die(mysql_error());mysql_close();}else{echo "må være et bilde";}?><html><body><form action="index.php" method="POST" enctype="multipart/form-data"><input type="file" name="file" /><br /><input type="submit" name="submit" /></form><a href='videos.php'>videos</a><?phpif(isset($_POST['submit'])){echo "<br />".$name." has been uploaded";}?></body></html> -
-
search engine
in PHP
i fixed it
-
search engine
in PHP
so here is my search engine script, and it works, but every time i refresh the page, all of the data in my database are displayed on my search.php page. Why?
What can i do?
<h1>search engine</h1><form action="./search.php" method="get"><input type="text" name="k" size='50' value="" /><input type="submit" name="submit" value='Search' /></form><hr /><?php@$k = $_GET['k'];$terms = explode(" ", $k);$query = "SELECT * FROM search WHERE ";foreach($terms as $each){@$i++;if($i == 1) {$query .= "keywords LIKE '%$each%' ";} else {$query .= "OR keywords LIKE '%$each%' ";}}include "connect.php";$query = mysql_query($query);$numrows = mysql_num_rows($query);if($numrows > 0){while($row = mysql_fetch_assoc($query)){$id = $row['id'];$title = $row['title'];$description = $row['description'];$keywords = $row['keywords'];$link = $row['link'];echo "<a href='$link'>$title</a><br />$description <br />";}}else{echo "ingen match funnet ved $k";}?> -
this is my php file upload.
How can i make sure that the user can only upload images and videos?
what type of if statement do i use?
<?phpinclude "connect.php";if(isset($_POST['submit'])){$name = $_FILES['file']['name'];$temp = $_FILES['file']['tmp_name'];move_uploaded_file($temp, "upload/".$name);$url = "http://localhost:81/upload/$name";mysql_query("INSERT INTO videos VALUES('','$name','$url')") or die(mysql_error());}?><html><body><form action="index.php" method="POST" enctype="multipart/form-data"><input type="file" name="file" /><br /><input type="submit" name="submit" /></form><a href="videos.php">videos</a><?phpif(isset($_POST['submit'])){echo "<br />".$name." has been uploaded";}?></body></html> -
this is my image code. Is there a way for me to make sure that all of it are displayed on the browser?
<html><body><form action="index.php" method="POST" enctype="multipart/form-data"><input type="file" name="file" /><br /><input type="submit" name="submit" /></form><?phpinclude "connect.php";if(isset($_POST["submit"])){$loc = "bilder/";if(($_FILES["file"]["type"] == "image/png") || ($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") ||($_FILES["file"]["type"] == "image/jpg")){$file = explode(".", $_FILES['file']['name']);mysql_query("INSERT INTO bilder VALUES('','".$file[0]."', '".$file[1]."')") or die(mysql_error());$id = mysql_insert_id();$newname = $id.$file[1];$path = "$loc$newname";move_uploaded_file($_FILES['file']['tmp_name'], $path);echo "du har lastet opp et bilde. klikk her <a href='$path'>klikk</a>";} else {echo "invalid file";}}?></body></html> -
i have created a guestbook for my website, but everytime i add a comment it just put the comment below the other. I want it so that the first page only shows maybe 35 comments, then a new page will be created and then 35 comments can be placed there etc.
echo "<h1>guestbook</h1>";
echo "<hr />";$form = "<form action='index.php' method='POST'><table><tr><td>name:</td><td><input type='text' name='name' /></td></tr><tr><td>message:</td><td><textarea rows='5' cols='30' name='message'></textarea></td></tr><tr><td></td><td><input type='submit' name='submit' /></td></tr></table></form>";include "connect.php";$getdata = mysql_query("SELECT * FROM guestbook ORDER BY id DESC");while($row = mysql_fetch_assoc($getdata)){$id = $row['id'];$name = $row['name'];$message = $row['message'];$date = $row['date'];$message = nl2br($message);echo "<table><tr><td><strong>lastet opp av $name. Dato: $date</strong></td></tr><tr><td>$message</td></tr><br /></table>";}echo "<hr />";$submit = $_POST['submit'];if($submit){$name = $_POST['name'];$message = $_POST['message'];if($name && $message){include "connect.php";$query = mysql_query("SELECT * FROM guestbook WHERE name='$name' && message='$message'");$numrows = mysql_num_rows($query);if($numrows == 0){mysql_query("INSERT INTO guestbook VALUES('','$name','$message',CURDATE())");echo "du har sent en melding $form";}else{echo "du kan ikke sende den samme meldingen om igjen $form";}}else{echo "du må fylle ut skjemaet $form";}}else{echo $form;}?> -
does anyone know any videos where i can learn how to both store and upload images to a databse, then retriew them in the browser?
-
video upload
in PHP
does anyone know how i can make a php video uploader script?
search engine
in PHP
Posted
this script is supposed to let me search by multiple keywords, but only lets me search by one at a time. The error i get when i try to type in several keywords is:
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:wampwwwsearch.php on line 32
<h1>search engine</h1>