son.of.the.morning
-
Posts
292 -
Joined
-
Last visited
Never
Posts posted by son.of.the.morning
-
-
I want to use javascript to open a confirmation box up before a record is deleted, but obviously when even you make a php page all the php code is executed first, any idears???
-
anyone???
-
Right i have made a new php file to delete the image but it keeps coming up 'Warning: unlink() [function.unlink]: http does not allow unlinking in /home/a2820511/public_html/testing/image-deleted.php on line 9'
This is how i have done it....
Table file
<?php while($rows=mysql_fetch_array($result)){ // Start looping table row ?> <tr> <td class="some-shit"><? echo $rows['id']; ?></td> <td class="some-shit"><a href="<? echo $rows['name']; ?>"><? echo $rows['name']; ?></a><br /></td> <td align="center" ><? echo $rows['type']; ?></td> <td align="center" ><? echo $rows['size']; ?></td> <td align="center" ><a href="image-deleted.php?id=<? echo $rows['name'] ?>"><img src="LAS/images/icons/admin/hds/delete.jpg" alt="" width="19" height="19" border="0" /></a></td> </tr> <?php // Exit looping and close connection } mysql_close(); ?>
Delete image file
<?php $imageDir=$_GET["id"]; unlink($imageDir); ?> <script language="text/javascript"> window.location ="delete-image.php"; </script>
-
I would rather do it on a whole new page becuase i want to have a confirm delete code plus i want to remove the record from the database to. I havnt got a clue were to start though
-
any idear on how the code should be in the delete page?
-
Basically i have a table show the contents of database (id, name, image type, image size). This is it,
http://dvplus.webuda.com/testing/delete-image.php
The image on the last column i want it have a href on that image that will delete the file directory that relevant on the table row. I tried to user <a href="<? unlink="" ?>img scr</a>.....,
any one got any idears???
-
Well ille have a wack at it and hope for the best , thanks allot for the help my good man.
-
do you think it is possible to have check form and use an array in unlink to remove more than one file at a time?
-
so if i dragged the file directory from the db and stored it in a varible say for istance $imgDir, and then used
unlink($imgDir); it will delete it.
-
So when an image is uploaded the path is stored inside a database, so i would just have to drag the contence out of the database from another page? Could you explain a litle more about how to delete the file?
-
I want to be able to view the contents of a folder in a table, each file having an individual row. The columns would be image name, type, size, and a delete option on the final column. Is this possible to do in php?
-
This part even...[
function upload_is_valid($upload, $valid_mime, $valid_ext) { if($upload['error'] != UPLOAD_ERR_OK) return false; $finfo = finfo_open(FILEINFO_MIME_TYPE); // Note: PHP 5.3.x if(!in_array(finfo_file($finfo, $upload['tmp_name']), (array) $valid_mime)) return false; if(!in_array(pathinfo($upload['tmp_name'], PATHINFO_EXTENSION), (array) $valid_ext)) return false; return true;}function upload_exists($upload, $directory) { $filename = pathinfo($upload['tmp_name'], PATHINFO_FILENAME); return file_exists(rtrim($directory, '\/') . DIRECTORY_SEPARATOR . $filename);}function upload_store($upload, $directory) { $upload = upload_create($upload); $filename = pathinfo($upload['tmp_name'], PATHINFO_FILENAME); return move_uploaded_file(rtrim($directory, '\/') . DIRECTORY_SEPARATOR . $filename);}function upload_create($upload) { // re-create the image return $upload;
-
I was actualy refering to...
function upload_is_valid($upload, $valid_mime, $valid_ext) { if($upload['error'] != UPLOAD_ERR_OK) return false; $finfo = finfo_open(FILEINFO_MIME_TYPE); // Note: PHP 5.3.x if(!in_array(finfo_file($finfo, $upload['tmp_name']), (array) $valid_mime)) return false; if(!in_array(pathinfo($upload['tmp_name'], PATHINFO_EXTENSION), (array) $valid_ext)) return false; return true;}function upload_exists($upload, $directory) { $filename = pathinfo($upload['tmp_name'], PATHINFO_FILENAME); return file_exists(rtrim($directory, '\/') . DIRECTORY_SEPARATOR . $filename);}function upload_store($upload, $directory) { $upload = upload_create($upload); $filename = pathinfo($upload['tmp_name'], PATHINFO_FILENAME); return move_uploaded_file(rtrim($directory, '\/') . DIRECTORY_SEPARATOR . $filename);}function upload_create($upload) { // re-create the image return $upload;}
-
i understand yours allot less then i do mine. lol
-
Thanx once again dude!
-
i dont get this "error" does it mean an error during the uload
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
/1024 ???
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
other than these i think i get it
-
haha i know i commented it but i still feel thre is more to it thats am not geting.
-
I would like to have more of a understanding of this upload file script if any one would like to be a pal and explain whats going on step by step, thats if it's not to much to ask of course .
<?php /* checking the file extension*/ if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/png"))) { /* this code will be executed if the file extension matches they above (gif,jpeg,png)*\ if ($_FILES["file"]["error"] > 0) /*if more than 0 errors occur the following code will be executed*/ { /* return code (string), $_FILES...(file var)*/ echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { /*listing file details, name, file type, file size*/ echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; /*temp file location*/ echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; if (file_exists("upload/" . $_FILES["file"]["name"])) { /* if there is a file already existing with the same name as the current file in a procedure then the following code will be executed*/ echo $_FILES["file"]["name"] . " already exists. "; } else { /*moving the successfully uploaded file to the a designated location, in this case upload/.*/ move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; } } } else { /*this section refers from the first if statement, if the file extension didn’t match the files listed at the beginning of this script then the following code will be executed.*/ echo "Invalid file extention” } ?>
-
Thanks guys.
Ignace, guessing you have come that far?
-
I would realy like to study php, other than taking other codes and editing them i havnt got a clue.
-
That fantastic guys, much appreciated.
-
Works fine guys, is it possible for one of use to explain how this $_sesion thingy works for futor refference?
-
Ok, Thanks Paul, and wildTeen. Ille let you know how i get on.
-
// Although sessioning a password is very dangerous ???
would this have to be done?
Php to action script? Help!
in PHP Coding Help
Posted
load the vars in to a dynamic text box give the text box a var name, then use an if statment like you normaly would.