Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include 'db.php';
- $statusMsg = '';
- $targetDir = "uploads/";
- $fileName = basename($_FILES["file"]["name"]);
- $test = $_POST["test"];
- $targetFilePath = $targetDir . $fileName;
- $fileType = pathinfo($targetFilePath,PATHINFO_EXTENSION);
- if(isset($_POST["submit"]) && !empty($_FILES["file"]["name"])){
- $allowTypes = array('jpg','png','jpeg','gif','pdf');
- if(in_array($fileType, $allowTypes)){
- if(move_uploaded_file($_FILES["file"]["tmp_name"], $targetFilePath)){
- $resultt = mysql_query("INSERT INTO images (name, test) VALUES ('".$fileName."', '".$test."')") or die (mysql_error());
- $statusMsg = "The file ".$fileName." has been uploaded successfully.";
- }
- }
- }
- echo $statusMsg;
- $result = mysql_query("SELECT * FROM `images` ORDER BY `images`.`id` DESC LIMIT 0 , 100") or die(mysql_error());
- while($row = mysql_fetch_array($result))
- {
- echo <<<html
- <img src="uploads/{$row['name']}" alt="" height="100" width="100" />
- <br />
- {$row['test']}
- html;
- }
- echo <<<html
- <form action="" method="post" enctype="multipart/form-data">
- בחר תמונה להעלה : <input type="file" name="file">
- <br />
- כתוב תוכן לבדיקה : <input type="text" name="test">
- <br />
- <input type="submit" name="submit" value="Upload">
- </form>
- html;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement