emediastudios
-
Posts
418 -
Joined
-
Last visited
Posts posted by emediastudios
-
-
I pasted your code over mine and now i get this.
Warning: move_uploaded_file(../news/) [function.move-uploaded-file]: failed to open stream: Permission denied in C:\Program Files\Apache Group\Apache2\htdocs\Prepare2win\admin\upload_news.php on line 18 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\Windows\TEMP\php1CB6.tmp' to '../news/' in C:\Program Files\Apache Group\Apache2\htdocs\Prepare2win\admin\upload_news.php on line 18 Sorry, there was a problem uploading your file. Warning: move_uploaded_file(../news/) [function.move-uploaded-file]: failed to open stream: Permission denied in C:\Program Files\Apache Group\Apache2\htdocs\Prepare2win\admin\upload_news.php on line 18 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\Windows\TEMP\php1CC7.tmp' to '../news/' in C:\Program Files\Apache Group\Apache2\htdocs\Prepare2win\admin\upload_news.php on line 18 Sorry, there was a problem uploading your file. Warning: move_uploaded_file(../news/) [function.move-uploaded-file]: failed to open stream: Permission denied in C:\Program Files\Apache Group\Apache2\htdocs\Prepare2win\admin\upload_news.php on line 18 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\Windows\TEMP\php1CC8.tmp' to '../news/' in C:\Program Files\Apache Group\Apache2\htdocs\Prepare2win\admin\upload_news.php on line 18 Sorry, there was a problem uploading your file.
???
Thanks for your help
-
Thanks for your help.
I did as you said and get this error
Parse error: syntax error, unexpected $end in C:\Program Files\Apache Group\Apache2\htdocs\Prepare2win\admin\upload_news.php on line 39
My code looks like this now
<?php require_once('../Connections/p2w.php'); ?> <?php //This is the directory where images will be saved $target = "../news/"; $target = $target . basename( $_FILES['photo']['name']); //This gets all the other information from the form $headline=$_POST['headline']; $contents=$_POST['contents']; $photo1=($_FILES['photo1']['name']); $photo2=($_FILES['photo2']['name']); $photo3=($_FILES['photo3']['name']); $title1=$_POST['title1']; $title2=$_POST['title2']; $title3=$_POST['title3']; $link=$_POST['link']; //Writes the photo to the server for ($x=1;$x<=3;$x++){ $photo ='photo'.$x; if(move_uploaded_file($_FILES[$photo]['tmp_name'], $target)){ //Tells you if its all ok echo "Success."; //Writes the information to the database mysql_query("INSERT INTO `news` VALUES (NULL,'$headline','$contents','$photo1','$photo2','$photo3','$title1','$title2','$title3','$link')") ; } else { //Gives and error if its not echo "Sorry, there was a problem uploading your file."; } ?>
-
Im a biginner in php
could you please explain how i do that.
sorry
-
i changed my code to this.
<?php require_once('../Connections/p2w.php'); ?> <?php //This is the directory where images will be saved $target = "../news/"; $target = $target . basename( $_FILES['photo1']['name']); //This gets all the other information from the form $headline=$_POST['headline']; $contents=$_POST['contents']; $photo1=($_FILES['photo1']['name']); $photo2=($_FILES['photo2']['name']); $photo3=($_FILES['photo3']['name']); $title1=$_POST['title1']; $title2=$_POST['title2']; $title3=$_POST['title3']; $link=$_POST['link']; //Writes the photo to the server if(move_uploaded_file($_FILES['photo1']['tmp_name'], $target)) { //Tells you if its all ok echo "Success."; //Writes the information to the database mysql_query("INSERT INTO `news` VALUES (NULL,'$headline','$contents','$photo1','$photo2','$photo3','$title1','$title2','$title3','$link')") ; } else { //Gives and error if its not echo "Sorry, there was a problem uploading your file."; } ?>
Only uploads the one file, i know why but how i get it to do the 3?
-
I have this code that works good, just have to implement some filters.
How would i change this code if i wanted to add 3 images instead of just the 1.
I have input fields and fields in my database called photo1, phot02 and photo3.
<?php require_once('../Connections/gcproperty.php'); ?> <?php //This is the directory where images will be saved $target = "../images/news/"; $target = $target . basename( $_FILES['photo']['name']); //This gets all the other information from the form $headline=$_POST['headline']; $link=$_POST['link']; $content=$_POST['content']; $photo1=($_FILES['photo'1]['name']); //Writes the photo to the server if(move_uploaded_file($_FILES['photo1']['tmp_name'], $target)) { //Tells you if its all ok print "<meta http-equiv=\"refresh\" content=\"0;URL=news_added_successfully.php\">"; //Writes the information to the database mysql_query("INSERT INTO `news` VALUES ('$headline','$photo1','$content','$link')") ; } else { //Gives and error if its not echo "Sorry, there was a problem uploading your file."; } ?>
-
I think
``application``
should be
`application`
u da man, wizzkid, your name says it all
dreamweaver, generated that code.
-
thanks, i changed it and it gave me this error
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '` WHERE id='1'' at line 1
thats with your code, ??? and when i have no (') i get what i had first?
Weird
-
Im some having trouble with deleting a record, surely it isnt that hard, dont know what im doing wrong.
this is the error i am gettin
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '` WHERE id=1' at line 1
Here is my delete code
<?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $currentPage = $_SERVER["PHP_SELF"]; if ((isset($_POST['id'])) && ($_POST['id'] != "")) { $deleteSQL = sprintf("DELETE FROM ``application`` WHERE id=%s", GetSQLValueString($_POST['id'], "int")); mysql_select_db($database_p2w, $p2w); $Result1 = mysql_query($deleteSQL, $p2w) or die(mysql_error()); $deleteGoTo = "application_deleted.php"; if (isset($_SERVER['QUERY_STRING'])) { $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?"; $deleteGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $deleteGoTo)); } $maxRows_Recordset1 = 2; $pageNum_Recordset1 = 0; if (isset($_GET['pageNum_Recordset1'])) { $pageNum_Recordset1 = $_GET['pageNum_Recordset1']; } $startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1; mysql_select_db($database_p2w, $p2w); $query_Recordset1 = "SELECT * FROM `application`"; $query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1); $Recordset1 = mysql_query($query_limit_Recordset1, $p2w) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); if (isset($_GET['totalRows_Recordset1'])) { $totalRows_Recordset1 = $_GET['totalRows_Recordset1']; } else { $all_Recordset1 = mysql_query($query_Recordset1); $totalRows_Recordset1 = mysql_num_rows($all_Recordset1); } $totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1; $queryString_Recordset1 = ""; if (!empty($_SERVER['QUERY_STRING'])) { $params = explode("&", $_SERVER['QUERY_STRING']); $newParams = array(); foreach ($params as $param) { if (stristr($param, "pageNum_Recordset1") == false && stristr($param, "totalRows_Recordset1") == false) { array_push($newParams, $param); } } if (count($newParams) != 0) { $queryString_Recordset1 = "&" . htmlentities(implode("&", $newParams)); } } $queryString_Recordset1 = sprintf("&totalRows_Recordset1=%d%s", $totalRows_Recordset1, $queryString_Recordset1); ?>
I have a record in my database with a incrementing primary key called id.
and a hidden field in the form with id posted within it.
Thanks for any help
-
I have no idea, i dont get any errors, just a blank page.
I added a filter and array butim sure its all wrong.
Heres my new code.
<?php //filter extensions $file_name = $file; function valid_ext($file_name) { $valid = array("jpeg","jpg","png","gif"); $extension = strtolower(substr($file_name,-3,3)); return (in_array($extension, $valid)); } ///Directory Settings $folder = "../images/"; $handle = opendir($folder); # Making an array containing the files in the current directory: while (false !== ($file = readdir($handle))) { if ($file != '.' && $file != '..') $files[] = $file; } closedir($handle); //Test Check $Valid = false; if(valid_ext($file_name)) #echo the files foreach ($files as $file) { echo "<img src='$folder$file' alt='image' width='150' /><br />"; echo "<a href='$folder$file'>$file</a> - "; echo "<a href=filedelete.php?file=$file>Delete this Image</a><br /><hr />"; } ?>
-
I have imported a function into the code but am unsure how to call upon it
<?PHP //filter extensions function valid_ext($file_name) { $valid = array("jpeg","jpg","png","gif"); $extension = strtolower(substr($file_name,-3,3)); return (in_array($extension, $valid)); } ///Directory Settings $folder = "../images/"; $handle = opendir($folder); # Making an array containing the files in the current directory: while (false !== ($file = readdir($handle))) { if ($file != '.' && $file != '..') $files[] = $file; } closedir($handle); #echo the files foreach ($files as $file) { echo "<img src='$folder$file' alt='image' width='150' /><br />"; echo "<a href='$folder$file'>$file</a> - "; echo "<a href=filedelete.php?file=$file>Delete this Image</a><br /><hr />"; } ?>
-
I have a code that displays all the files in a folder as well as a thumbnail image.
This is a page that allows my client the option to delete a image from his dir if it is no longer needed.
I was hoping that i could alter my code so that it only displayed images in jpg, jpeg, gif or png.
and if there is files or folders that are not of this format in the selected(../images) directory, not echo them.
Here is my code.
<?PHP $folder = "../images/"; $handle = opendir($folder); # Making an array containing the files in the current directory: while (false !== ($file = readdir($handle))) { if ($file != '.' && $file != '..') $files[] = $file; } closedir($handle); #echo the files foreach ($files as $file) { echo "<img src='$folder$file' alt='image' width='150' /><br />"; echo "<a href='$folder$file'>$file</a> - "; echo "<a href=filedelete.php?file=$file>Delete this Image</a><br /><hr />"; } ?>
MAny thanks.
Oh i have this code too, maybe i could use some code out of it and combine it with the upper code?
<?php echo "<select name=\"file\">\n"; foreach (new DirectoryIterator('.') as $file) { // if the file is not this file, and does not start with a '.' or '..', // then store it for later display if ( (!$file->isDot()) && ($file->getFilename() != basename($_SERVER['PHP_SELF'])) ) { echo "<option>"; // if the element is a directory add to the file name "(Dir)" echo ($file->isDir()) ? "(Dir) ".$file->getFilename() : $file->getFilename(); echo "</option>\n"; } } echo "</select>\n"; ?>
-
Thanks, yeah i will give it a go, i always do, but this project is well overdue and im getting eager to wrap it up as its so close.
Thanks for your help
-
now all i got to do is sort out the filedelete.php
I was given this code below but nothing, justs timesout
<?php $filename = 'gcproperty/images'.$_GET['file']; $file = $_GET['file']; // set up basic connection $ftp_server = "localhost"; $ftp_user_name = "root"; $ftp_user_pass = "5050888202"; $conn_id = ftp_connect($ftp_server); // login with username and password $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); // try to delete $file if (ftp_delete($conn_id, $filename)) { echo "<p><center>The file $filen was deleted successfully.<br />"; echo "<center><a href=admin.php>Back</a>"; } else { echo "<p><center>Could not delete $file.<br />"; echo "<center><a href=admin.php>Back</a>"; } // close the connection ftp_close($conn_id); ?>
-
worked it out
Silly me
echo "<img src='$folder$file' alt='image' width='150' /><br />";
-
sorry here is the code
<?php echo "<img src='$folder$file'> alt='image' width='150' /><br />";?>
-
ok i now have the images displaying ;D
but it just echos this code alt='image' width='150' /> beside the image ???
-
i have this code
<?php echo "<img src='$folder$file' alt="image" width="150" /><br />";?>
and i get this error
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\Program Files\Apache Group\Apache2\htdocs\gcproperty\admin\filelist.php on line 17
-
need some repair to this code
<?php echo "<img src='$folder$file' alt="image" width="150" /><br />'; ?>
-
i did this and the link works now
<?php echo "<a href='$folder$file'>$file</a><br />"; ?>
now for the thumnail
it still doesnt display
-
loaded the page and read the souce code. its here
<?php <a href=../images/Conventoncntr.jpg><label title=Conventoncntr.jpg>Conventoncntr.jpg</a><br /></label><img src="$folder$file" alt="image" width="150" /><br /><a href=filedelete.php?file=Conventoncntr.jpg>Delete</a><br /> ?>
something not right there.
this is the code generated from
<?php #echo the files foreach ($files as $file) { echo "<a href=$folder$file><label title=$file>$file</a><br /></label>"; echo '<img src="$folder$file" alt="image" width="150" /><br />'; echo "<a href=filedelete.php?file=$file>Delete</a><br /><br />"; } ?>
-
seems so strange as the file names echo correctly, why doesnt the link or thumnail work.
Code again with a couple of changes
<?PHP $folder = "../images/"; $handle = opendir($folder); # Making an array containing the files in the current directory: while (false !== ($file = readdir($handle))) { if ($file != '.' && $file != '..') $files[] = $file; } closedir($handle); #echo the files foreach ($files as $file) { echo "<a href=$folder$file><label title=$file>$file</a><br /></label>"; echo '<img src="$folder$file" alt="image" width="150" /><br />'; echo "<a href=filedelete.php?file=$file>Delete</a><br /><br />"; } ?>
-
no error messages, just an empty image box.
i get the file name echoed
but when i click on it nothing. ???
-
This part of the code should open the image also
<?php echo "<a href=$folder$file><label title=file>$file</a><br /></label>"; ?>
but it doesnt
???
-
As i am a newbie i think i may of found a little problem. When you are echoing the file location within the html ''img scr'' you need to include the full path details and not just $file, which is the name of the file. You need to set up a variable that contains both $folder and $file
Gave that a go before, it didnt work either.
thanks for trying champ, and yes that makes sense
[SOLVED] Upload More images
in PHP Coding Help
Posted
The directory exists.
and i have other upload files that work.
this is strange.