Jump to content

Upload 2 files to a directoryand database at the same time.


imrie

Recommended Posts

Ok, i have a file uploader where you can upload a .zip and a .bmp/.jpg/.gif etc. now i send these to files to seperate directorys (Pics) + (Downloads), i also send both of these files data into a the same row of a mysql database. (Anyone know this code). I then need to use a mysql SELECT statment to display the image and the download link side by side. What is the code to display them side by side and have an image not a llink to the image?What is the code to send both of these files to the database as described above?Sorry, its a lot of help needed. :) These files (image and .zip) always have to be together. ( The image and the download)Also is it possible to set something so that i can count the number of clicks on the file link. By creating another field to the database.Thanks very much, i really need the code for it.PS, it is possible to upload 2 files at the same time, isint it?

Link to comment
Share on other sites

Check here for information on file uploads, including uploading multiple files:http://www.php.net/manual/en/features.file-upload.php

What is the code to display them side by side and have an image not a llink to the image?
PHP isn't responsible for displaying anything, HTML is. You would create an HTML template to lay out two items next to each other, and then use PHP inside that template to write out the actual pieces of content. You would use the <img> tag to show an image, and have PHP write out the src attribute to point to whatever image you want to show.
What is the code to send both of these files to the database as described above?
You don't really "send" the file to the database. You just save it on the server. You need to save the uploaded files (see the link above), and then it's recommended that you just save the filenames in the database. If you want to save the binary data in the database, then you would use file_get_contents to read the file as a string and store that string in a blob field in the database.The code for two files is just like the code for one file, only you do it twice.
Also is it possible to set something so that i can count the number of clicks on the file link. By creating another field to the database.
You can include a counter field in the database. But you can't link directly to the file. You would need to link to a PHP page, like this:download.php?file=123figure out which file they are trying to download, increment the counter in the database, and then redirect to the actual file.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...