Announcement

Collapse
No announcement yet.

Attachment Questions

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • [Forum] Attachment Questions

    Hi there,

    I have a few questions about how uploads work in vBulletin 4.1.10.

    I notice that the original files are no longer in my uploadstore folder, but that .attach files are. I'm assuming vBulletin has some sort of encryption on the original files?
    I contacted support but they just told me I can't upload and keep my original files and their names.

    Is there anyway of being able to use my uploaded files in vB with another PHP script, such as a file manager for example?

    All I wan't to do is upload a ZIP through vBulletin, extract it to another folder and use the files within, in another script. Saves uploading twice, but I can't do anything with .attach files.

    Thank you very much for you time.

  • #2
    I suggest you explain what you're wanting to do because it's not at all clear from your post.

    Comment


    • #3
      Yes sorry I read that back and it dosen't sound clear at all.

      Well, certain users can post a thread that showcases music they have created, as a ZIP, using the attachment feature.

      I am creating a separate script that will unzip the upload, and copy the music files to another directory so that my Kplaylist (Audio streaming PHP script) can stream the music.

      But, I am not sure I can unzip .attach files, even though they are just renamed to .attach. Plus, I don't understand how vB organises it's attachments (why are there "1" and "2" folders etc. and what determines the file name?)

      It is just so users don't have to upload the same files twice, once ZIPped and again with seperate files.

      Thank you for your time.

      Comment


      • #4
        Files are stored in folders according to the userid. For example if userid 13532 uploads a zip it will be in folder:

        1/2/5/3/2/filename.attach

        The problem with what you are wanting to do is you will have orphaned files if the original attachment is deleted or the post is deleted. A better approach would be to write your script so that the zip file is uncompressed each time the attachment is clicked. That way you can delete any files in the temp folder before unzipping the file the members is wanting to look at.

        How do you plan on making the zip attachment clickable?

        Comment


        • #5
          I'm not fully sure of what you mean there, but I plan on keeping the .attach files intact. I just need the files inside the ZIP to be copied to another directory and a way to identify which .attach is which file.

          I'm currently just gathering my possibility's at the moment on how I can achieve this. Two uploads is just not acceptable :/

          Thank you.

          EDIT--

          Had an idea. Is there anyway to display the actual path to an attachment using template variables or some other way using PHP. Because I could add a submit button next to the attachment that submits the URL to the unzipping script? Hidden of course from other users.
          Last edited by joshkrz; Mon 5 Mar '12, 2:31pm. Reason: Had an idea :)

          Comment


          • #6
            Okay lets take this one step at a time.

            1) The .attach file remains intact.
            2) If you unzip the attach file to another directory, you need a way to manage these files. The reason is what happens if the user deletes the attachment, you don't want orphaned files.

            Does that make sense?

            Comment


            • #7
              OK, I understand now. But orphaned files in the audio directory would not be an issue. If the user wants them deleted he can request it.
              I would like for this process to be manual, not automatic because all uploads are not just audio.

              So, If I can pass the raw address of the attachment, to the unzip script, from the thread page (so i know what file it is I'm unzipping ) then I can make this work, in theory.

              Cheers.

              Comment


              • #8
                Originally posted by joshkrz View Post
                OK, I understand now. But orphaned files in the audio directory would not be an issue. If the user wants them deleted he can request it.
                As long as you're aware of the problem. Ideally you design the software to be able to account for these orphaned files one way or another.

                Originally posted by joshkrz View Post
                I would like for this process to be manual, not automatic because all uploads are not just audio.

                So, If I can pass the raw address of the attachment, to the unzip script, from the thread page (so i know what file it is I'm unzipping ) then I can make this work, in theory.

                Cheers.
                This is what I suggest.

                1) Create a custom bbcode called audio. So if a person uploads a zip file that contains audio files, they wrap the attachment id like this in their post:

                [audio]187367[/audio]

                That way when viewing the post anyone can click the audio bbcode and your script is run, the the audio files contained in that zip attachment will be displayed and can be played.

                Comment


                • #9
                  Wow that is a fantastic idea.

                  Just two things though:
                  -Where does the user find the attachment ID?
                  -If I have the attachment ID and can pass it to the unzip script, how would I relate, for example, attachment 187367, to the raw address of the file?

                  Thank you once again, I appreciate the help with this.

                  Comment


                  • #10
                    Originally posted by joshkrz View Post

                    -Where does the user find the attachment ID?
                    If they click the paperclip down arrow the attachment can be inserted inline, they just change it as follows:

                    [ attach]187367[ /attach]

                    to

                    [audio]187367[/audio]

                    Originally posted by joshkrz View Post

                    -If I have the attachment ID and can pass it to the unzip script, how would I relate, for example, attachment 187367, to the raw address of the file?

                    Thank you once again, I appreciate the help with this.
                    Your script will query your database directly. You have the attachment number from the {param} in your custom bbcode. Just query the attachment table for the userid and filedataid. With that information you can find the .attach in your folder directory.

                    Comment


                    • #11
                      Well that sorts my problem out perfectly. Thank you for your help

                      Comment


                      • #12
                        Originally posted by joshkrz View Post
                        Well that sorts my problem out perfectly. Thank you for your help
                        Happy to help.

                        Comment

                        widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                        Working...
                        X