Page 1 of 1
help wit uploading and displaying images and videos wit php
Posted: Wed Jan 14, 2009 7:06 am
by joeyxaza
hi all, can anyone help me with the code on how to upload and display images and videos in php, i'm a newbie and would like to have an idea on how it is done, thanks
Re: help wit uploading and displaying images and videos wit php
Posted: Wed Jan 14, 2009 7:57 am
by watson516
Do you have any code yet?
Re: help wit uploading and displaying images and videos wit php
Posted: Wed Jan 14, 2009 8:13 am
by jaoudestudios
Google 'php upload'. Try and put something together, if you get errors let us know.
Re: help wit uploading and displaying images and videos wit php
Posted: Fri Jan 16, 2009 5:33 am
by joeyxaza
this is my current code:
<?php
define('storage','c:\\inetpub\\wwwroot\\newnfa\\images');
$conn = mysql_connect('localhost','root','jivers') or die(mysql_error());
mysql_select_db('imagetest') or die(mysql_error());
$name = $_POST['name'];
$sql = "insert into test values('$name')";
$result = mysql_query($sql) or die(mysql_error());
if(is_uploaded_file($_FILES['upload']['tmp_name']))
{
if($_FILES['upload']['type'] != "image/jpeg")
{
echo "image must be in jpeg format";
}
else
{
$result = move_uploaded_file($_FILES['upload']['tmp_name'],storage."\\$name.jpeg");
if($result == 1)
echo "success";
else
echo "failure";
}
}
?>
this is the error i get when i execute the script?
failurePHP Warning: move_uploaded_file(c:\inetpub\wwwroot\newnfa\images\xaza.jpeg) [function.move-uploaded-file]: failed to open stream: Permission denied in c:\Inetpub\wwwroot\imageload.php on line 22 PHP Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\WINDOWS\TEMP\php63.tmp' to 'c:\inetpub\wwwroot\newnfa\images\xaza.jpeg' in c:\Inetpub\wwwroot\imageload.php on line 22
Re: help wit uploading and displaying images and videos wit php
Posted: Fri Jan 16, 2009 6:52 am
by jaoudestudios
The error states that the folder you are trying to move the image to, will not allow you to move the file in there as you do not have the relevant permissions.