Hi Guys,

I've been looking around on the net for a solution to something I am trying to build. Many options out there, but can't quite grasp them enough to get them to work. I had built a simple uploader and it had worked, and I may just go back to it, but I want to see if anyone has insight to what I want to achieve as an end result.

The Objective

The Uploader Index page has a form with the following fields:
Type
Caption
Picture
Thumbnail
Added By (This field is auto filled based on session username)
Added On (This field is auto filled by date function)

This information posts back to a table in my database. Which works fine if I dont use input file tags. Maybe Im missing something...

Now what I would like to do is:
1) Use ajax to be able to upload multiple files in one shot. No Limit to Files count, file size would be 5 MB.
2) Create an If statement which I think would appear as:

<?php $format = $_POST['type'];
if ($format=="Image")
echo \\INSERT UPLOAD TO IMAGE DIRECTORY CODE HERE
elseif ($format=="Movie")
echo \\INSERT UPLOAD TO VIDEO DIRECTORY CODE HERE
; ?>

I know I put insert comment lines there, that is because I'm not sure of what to use. All Videos will use an FLV format, pictures can be any picture format.

Now on upload, I need it to add "image-" to all images and "thumb-" to all my thumbs, as the gallery I already built with AJAX and PHP Database, work already.

3) An Auto thumbnail creation method? If not possible I can work around that.

So in bassis, I'm looking for a solution that can do the above for me. If anyone knows where I can find a code to start from. The basis of just combining different tutorials is not helping me one bit so far.

Thanks everyone.

    Thumbnail creation has been hashed over and over and over here at PHPB. You might want to search the forums a bit (read: I know I've posted on the subject quite a few times).

    Your if() statement should really be looking at the $_FILES array seeing as that's where the files would come in to. You would want to use the MIME type to define what kind of file it is (image, video, mp3, etc.).

    As for a project with AJAX uploads, I'm not 100&#37; sure, but RoundCube Webmail may do an AJAX upload; however, I haven't looked at the source recently so I'm not 100% sure about that. But they do an all AJAX Webmail client, so you should be able to pick up some nifty code from them 😉

      Ya I currently use Roundcube Webmail as my webmail service, I should more into that.

      Thanks.

      AS for the rest i figured if I used a input field to define if it was simply a movie or and image not regarding what the actual file type is, it would be simpler than letting the query handle the discovery.

        8 days later

        It's sometimes safer to let the server figure it out. People could just as easily hide malicious code behind a jpg or png file which when served could be other content, or could be a "dynamic" png. So if you always send the specific header, malicious code won't do much.

          Write a Reply...