Jump to content

Scarleta

New Members
  • Content Count

    3
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Scarleta

  • Rank
    Newbie
  1. Thanks for your message. I just posted my issues and the codes.
  2. I need urgent help! For two days I've been trying to find the source code to upload image to database and display, after trying all the codes I kept getting all sorts of errors. I'm using phpmyadmin. 1) Upload & Display image of any size < 5mb 2) upload & provide click-able link for PDF size file < 10mb 3) restrict up to only 3 latest posts on a page It works by inserting the picture into database but doesn't allow me to upload more than 500kb which results in partial or no display. upload.php [code] upload.php <?php include "_database.php"; if (isset($_FILES['image']) && $_FILES['image']['size'] > 0) { $tmpName = $_FILES['image']['tmp_name']; // Read the file $fp = fopen($tmpName, 'r'); $data = fread($fp, filesize($tmpName)); $data = mysqli_real_escape_string($conn,$data); fclose($fp); // Create the query and insert // into our database. $query = "INSERT INTO picture (picture1) VALUES ('$data')"; $results = mysqli_query($conn,$query) or die("fail connect"); // Print results print "Thank you, your file has been uploaded."; echo "<a href='action.php'>main</a>"; } else { print "No image selected/uploaded"; } // Close our MySQL Link ?> <?php #to display picture code //php echo '<img src="data:image/jpeg;base64,'.base64_encode( $row['picture1'] ).'"/>'; dont forget to add the open php and close ?> action.php This is for display, apparently, picture cannot be properly uploaded because of file size. <?php include "_database.php"; ?> <html> <head><title></title></head> <style> table tr td { border:1px solid black; } #size { display:block; } </style> <body> <form enctype="multipart/form-data" action="upload.php" method="post" name="changer"> <input name="MAX_FILE_SIZE" value="2048000000" type="hidden"> <input name='image' type="file"> <input value="Submit" type="submit"> <table > <tr> <td>ID</td> <td>picture</td> <td>display</td> </tr> <tr> <?php $link1 = "SELECT * FROM picture"; $result = $conn->query($link1) or die ("fucking"); if($result->num_rows>0){ while($row = $result->fetch_assoc()){ ?> <td><?php echo $row["ID"];?></td> <td><div id="size"><?php echo '<img src="data:image/jpeg;base64,'.base64_encode( $row['picture1'] ).'"width="200px" height="500px"/>'; ?></div></td> <td><a href="display.php?id=<?php echo $row["ID"];?>">display</a></td> </tr> <?php } } ?> </table> </body> </html>
  3. I need urgent help! For two days I've been trying to find the source code to upload image to database and display, after trying all the codes I kept getting all sorts of errors. I'm using phpmyadmin. Fatal error: Call to undefined function finfo_open() in C:\xampp\htdocs\geology\file_insert.php on line 51 Second help needed is to display or restrict 3 latest posts only. I want to display only 3 latest posts sort by latest date posted. I'm not sure how to loop this through. Another thing is, when the user clicks on the title of a specific article, a new window will appear to display only the data that belong to it (Title, Publisher, Content...) For example, there are 3 articles (rock, mineral, salt) user clicks on Rocks, a new window appear showing all Rocks info. <?php $sql = "select * from article ORDER by article_postdate DESC"; $result = mysqli_query($conn, $sql); while($row = mysqli_fetch_assoc($result)) { ?> <h3><a href="#"><?php echo $row["article_title"]; ?></a></h3> <p class="byline"><span><?php echo $row["article_postdate"]; ?><br> Published By:<?php echo $row["author_id"]; ?></p></a></span></p> <p><?php echo $row["article_details"]; ?></p> <td><a href = "edit.php?article_id=<?php echo $row['article_id']; ?>">More...</a></td> <?php } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.