24. februar 2003 - 10:50Der er
9 kommentarer og 1 løsning
pop-up not popping up
well i've fixed some of the bugs so now it uploads, i have two probs i cannot seem to get passed. one of them is that some pictures i upload dont seem to fully go over, only part of the picture. but the main prob is that the pop-up link i create does not pop-up. am i missing something?? here's the script that does it, or not as the case maybe. as always feel free to reply in danish.
Description: Demonstrate how to upload a file and then later displaying a list of the images already uploaded providing a link. this will open in a new window, sized 800*650. This is done with Javascript.
----------------END OF HEADER---------------- */ require_once("db.file");
/* -Loop through all the uploaded files submitted -Functions used:
-is_uploaded_file( string name ) : Returns TRUE if the file named by filename was uploaded via HTTP POST. -move_uploaded_file( string filename, string destination ) : This function checks to ensure that the file designated by filename is a valid upload file (meaning that the file was uploaded vis PHP's HTTP POST mechanism. If the file is valid, it will be moved to the filename given by destination. */
function move_files() { global $HTTP_POST_FILES, $file_dir; // make the whole array global $file_dir="/var/www/html/uploads/"; //path to upload dir
/* -This function takes care of inserting the new image and caption into the images table -Calls move_files() before inserting into table, better to have a stay image with no entry in the table than having an entry in the table and no image to go with it. -Assumes that table "images" exsits */
function commit() { global $link, $img_name, $img_caption; // this function take the current time in seconds from Epoch(Jan 1, 1970 00:00:00) $time_stamp=time();
move_files();
//insert new row into images $insert_query="INSERT INTO images (img_name, img_caption, date_auto) VALUES ('$img_name', '$img_caption', '$time_stamp')";
send_query($insert_query,$link); }
/* Some checking needs to be done here to make sure that these vars conatin a value. can be done with Javascript (then no checking needs to be done here as then we are sure that the vars contain something) field type script.. */
<body> <form action="<?= $_SERVER['PHP_SELF'] ?>" method="POST" enctype="multipart/form-data" name="uploadform"> Image:<input type="file" name="imageupload"><br><br> Caption: <input type="text" name="caption"><br><br> <input type="submit" name="submit" value="Send Image"> </form> <br> <p> Here's a list of all the images uploaded: <?php
echo 'File Dir: '.$file_dir; $query="SELECT * from images ORDER by date_auto DESC"; // newest reviews at top $data=send_query($query, $link); echo '<ol>'; // start ordered list for ($i=0;$i < mysql_num_rows ($data);$i++) { //get all values needed for output /* function used : mysql_result (resource result, int row, mixed field) mysql_result() returns the contents of one cell from a mysql result set. The field argument can be fields offset, or the fields name, or the fields tabel dot field name (tablename.fieldname) . */
Description: Demonstrate how to upload a file and then later displaying a list of the images already uploaded providing a link. this will open in a new window, sized 800*650. This is done with Javascript.
----------------END OF HEADER---------------- */ require_once("db.file");
/* -Loop through all the uploaded files submitted -Functions used:
-is_uploaded_file( string name ) : Returns TRUE if the file named by filename was uploaded via HTTP POST. -move_uploaded_file( string filename, string destination ) : This function checks to ensure that the file designated by filename is a valid upload file (meaning that the file was uploaded vis PHP's HTTP POST mechanism. If the file is valid, it will be moved to the filename given by destination. */
function move_files() { global $HTTP_POST_FILES, $file_dir; // make the whole array global $file_dir="/var/www/html/uploads/"; //path to upload dir
/* -This function takes care of inserting the new image and caption into the images table -Calls move_files() before inserting into table, better to have a stay image with no entry in the table than having an entry in the table and no image to go with it. -Assumes that table "images" exsits */
function commit() { global $link, $img_name, $img_caption; // this function take the current time in seconds from Epoch(Jan 1, 1970 00:00:00) $time_stamp=time();
move_files();
//insert new row into images $insert_query="INSERT INTO images (img_name, img_caption, date_auto) VALUES ('$img_name', '$img_caption', '$time_stamp')";
send_query($insert_query,$link); }
/* Some checking needs to be done here to make sure that these vars conatin a value. can be done with Javascript (then no checking needs to be done here as then we are sure that the vars contain something) field type script.. */
<body> <form action="<?= $_SERVER['PHP_SELF'] ?>" method="POST" enctype="multipart/form-data" name="uploadform"> Image:<input type="file" name="imageupload"><br><br> Caption: <input type="text" name="caption"><br><br> <input type="submit" name="submit" value="Send Image"> </form> <br> <p> Here's a list of all the images uploaded: <?php
echo 'File Dir: '.$file_dir; $query="SELECT * from images ORDER by date_auto DESC"; // newest reviews at top $data=send_query($query, $link); echo '<ol>'; // start ordered list for ($i=0;$i < mysql_num_rows ($data);$i++) { //get all values needed for output /* function used : mysql_result (resource result, int row, mixed field) mysql_result() returns the contents of one cell from a mysql result set. The field argument can be fields offset, or the fields name, or the fields tabel dot field name (tablename.fieldname) . */
btw, the thing missing was the ' around the parrameter when calling the JS function ;) hence the extra \' in the function call... and changed the 's to "s as I tend to like them better ;) no special reeason for that change ;)
ok i pasted in that code you wrote. i can see that youe eg works - but for some reason i get FILE NOT FOUND and it writes the direct path to me uploads dir eg /var/www/html/uploads/mypicture.jpeg. not found on this server. but when i check the folder its in there...
accepted your answer dea. still cannot get mine working but will give you the points for your working example. 8]-)
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.