Join 244,161 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,353 people online right now. Registration is fast and FREE... Join Now!
Hey guys, I'm trying to make a image uploader for my site with PHP, I'm a total beginner at PHP so bear with me. I want there to be a "recently uploaded" part, with 6 of the most recently uploaded images, is that possible?. Heres a mockup. Mockup Actually works , IP logging works too, and the ban script, but my main problem is the recently uploaded thing, can anyone help?.
<div style="background: #1e1e1e; border: 4px solid #7c7360; padding: 20px; width: 500px;" > <center><img src="http://www.iconspedia.com/uploads/762332078.png"></img></center> Use the tool below to upload images, maximum size is 3mb's, Jpg,gif and bmp are the only supported formats. <h2>Sig hosting - CoDCreators.com</h2> <form action="upload_ac.php" method="post" enctype="multipart/form-data" name="form1" id="form1"> Select file <input name="ufile" type="file" id="ufile" size="50" /></td> <input type="submit" name="Submit" value="Upload" /> <br> <hr></hr> <h2>Recently uploaded</h2> <?php //set where you want to store files //in this example we keep file in folder upload //$HTTP_POST_FILES['ufile']['name']; = upload file name //for example upload file name cartoon.gif . $path will be upload/cartoon.gif $path= "files/".$HTTP_POST_FILES['ufile']['name']; echo "<img src=\"$path/latest.jpg\" width=\"150\" height=\"150\">"; echo "<img src=\"$path/Blue hills.jpg\" width=\"150\" height=\"150\">"; echo "<img src=\"$path/Water lilies.jpg\" width=\"150\" height=\"150\">"; echo "<img src=\"$path/Winter.jpg\" width=\"150\" height=\"150\">"; echo "<img src=\"$path/me.jpg\" width=\"150\" height=\"150\">"; echo "<img src=\"$path/1-1.jpg\" width=\"150\" height=\"150\">"; echo "<br>Do NOT post any pornographic images, it will be deleted immediately, your IP is being logged."
<h2>Sig hosting - CoDCreators.com</h2> <?php //set where you want to store files //in this example we keep file in folder upload //$HTTP_POST_FILES['ufile']['name']; = upload file name //for example upload file name cartoon.gif . $path will be upload/cartoon.gif $path= "files/".$HTTP_POST_FILES['ufile']['name']; if($ufile !=none) { if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path)) { echo "Successful<BR/>";
I'd store the data into a database, and if you wanted immediate front end integrationon-the-fly as you're uploading, you could impliment AJAX to echo out the latest '6' as you go along.
To do this, insert the file data into your database table, along with a timestamp. Then to show the 'latest six downloads/uploads' you can pull the results using a query like:
CODE
SELECT * FROM tbldocs ORDER BY timestamp LIMIT 6
This eliminates the need to post serialized arrays / ids etc and will still be there the next time you log on to the application, unlike a $_SESSION or $_POST data
I'd store the data into a database, and if you wanted immediate front end integrationon-the-fly as you're uploading, you could impliment AJAX to echo out the latest '6' as you go along.
Yes, that would probably best. I wasn't thinking about the need to keep track of the array between sessions. Of course, if you don't have a database you could write to a text file. It is only six lines.
Ok I've set up my databases and everything, but I get this error when I go to upload.
CODE
Warning: mysql_query() [function.mysql-query]: Access denied for user 'codcreat'@'localhost' (using password: NO) in /home1/codcreat/public_html/jdogg/upload/upload_ac.php on line 86
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home1/codcreat/public_html/jdogg/upload/upload_ac.php on line 86 Bann List Unavalible
My username isnt codcreat and my password isnt NO. This is my config.php
<h2>Sig hosting - CoDCreators.com</h2> <?php //set where you want to store files //in this example we keep file in folder upload //$HTTP_POST_FILES['ufile']['name']; = upload file name //for example upload file name cartoon.gif . $path will be upload/cartoon.gif $path= "files/".$HTTP_POST_FILES['ufile']['name']; if($ufile !=none) { if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path)) { echo "Successful<BR/>";
Replicate exactly what you expect it to be doing in code, at the command line. Make sure the values you expect to work do in fact work.
I don't know what you mean sorry. Like a sudo code?.
CODE
Upload Image.jpg, if the upload is completed submit ip, size of image.jpg, name of image.jpg, the date and time image.jpg was created, and the id of image.jpg
Hey guys, I'm trying to make a image uploader for my site with PHP, I'm a total beginner at PHP so bear with me. I want there to be a "recently uploaded" part, with 6 of the most recently uploaded images, is that possible?. Heres a mockup. Mockup Actually works , IP logging works too, and the ban script, but my main problem is the recently uploaded thing, can anyone help?.
Hey JDogg..... well m new to but as i see no code.... i see pitty and thought of helping out! I have completed the part of uploading images to a mysql database... hope this helps if it does drop me a message! i Have attached 2 php files that would do the trick!