Results 1 to 3 of 3

Thread: Getting full control of image uploader

  1. #1
    Join Date
    Aug 2001
    Location
    Indonesia
    Posts
    3,732

    Default Getting full control of image uploader

    You can let webmaster to upload image for their resource/link. You have full control of allowed image that can be uploaded: max image size (height and width), and file extention. You can also have more than one image, you can have as many as you need.

    How to upload image

    First, you need a field which its type is image. In order to add new field, go to admin cp -> database tables -> alter -> add new field.

    As admin, you can upload image for specific resource in admin cp -> links -> View/Edit/Delete or Search -> [edit]. Then you'll find [upload] in proper image field. Click it to upload image.

    Before webmaster can upload their image, their resource/link should be approved and listed first. They can't upload image when adding/submitting their resource.

    In order to upload image, webmaster should go to "modify resource" section. They'll find link "Upload Image". Click the link and the upload form will appear.


    Controlling max width and max height

    When webmaster getting their modify form, the link to upload image is
    Code:
    javascript: 
    MM_openBrWindow('upload.php?id=29&f=myimage&mw=100&mh=100',
    'myimage','status=yes,menubar=yes,width=400,
    height=200')
    It will run javascript called MM_openBrWindow (the code is in modify_form.html). It will open new window with:
    - url: upload.php?id=29&f=myimage&mw=100&mh=100
    - window name is myimage (depend on your image field name)
    - status bar
    - menu bar
    - width=400
    - height=200

    The most important is the url:
    - file name: upload.php
    - id -> resource id: 29
    - f -> field name: myimage
    - mw -> max width: 100 pixel
    - mh -> max height: 100 pixel

    Now, how to change mw and mh?
    Edit /themes/default/msg.php line 339-343
    PHP Code:
    $msg["10143"] = "
      <a href=\"javascript: MM_openBrWindow(
    'upload.php?id=<%link_id%>&f=<%field_name%>&mw=100&mh=100',
    '<%field_name%>','status=yes,menubar=yes,width=400,height=200')\">
      Upload Image
      </a>
    "

    Just change mw and mh to any number as you wish.


    Controlling allowed file extention

    It's very easy, you can use admin cp. Go to admin cp -> Application -> Setup -> Miscellaneous -> Allowed File Extention. Just fill the field with list of file extentions separeted by comma ",". Remember, do not add any space otherwise it will recognized as a part of file extention.


    Having more images

    Add new image field in admin cp


    How images are stored

    By default, all image will be stored in folder /upload_files. To store in different folder name, you need to edit /themes/default/upload_form.html

    <form action="upload.php" method=post ENCTYPE="multipart/form-data">
    <input type=hidden name=pflag value=upload>
    <input type=hidden name=link_id value=<%link_id%>>
    <input type=hidden name=folder value=upload_files>
    <input type=hidden name=f value=<%f%>>
    <input type=hidden name=mw value=<%mw%>>
    <input type=hidden name=mh value=<%mh%>>

    Change the value of
    <input type=hidden name=folder value=upload_files>
    to any folder name, e.g.:
    <input type=hidden name=folder value=user_files>

    Do not forget to set the folder permission properly. Allow anyone to write file, chmod 766 should work.

    Now about the image file name that stored in above folder. Indexu will rename the filename with pattern:

    fieldname_resourceid

    So myimage_29.jpg is the image for resource id 29, image field myimage


    Disable webmaster to upload image

    You should first disable "auto generate custom field". By default, indexu will generate custom field form automatically. If you add new database field in admin cp, if the field type is:
    - text -> generate multiline edit box <textarea></textarea>
    - image -> generate upload image link
    - others -> generate single line edit box <input type=text>

    To prevent indexu generate them automatically, you must remove

    <%custom_field_form%>

    in add_form.html
    and modify_form.html

    Then you should manually add form for custom fields:
    e.g.:

    single line edit box:
    PHP Code:
            <tr>
              <
    td valign=top><font face="Arial" size="2">language</font></td>
              <
    td>
    <
    input type=text name="language" size=40 value="">
    <
    font face=arial color=green size=2></font></td>
            </
    tr
    multiline edit box:
    PHP Code:
            <tr>
              <
    td valign=top><font face="Arial" size="2">comment</font></td>
              <
    td><textarea name="comment" cols=40 rows=6></textarea>
    <
    font face=arial color=green size=2><br></font></td>
            </
    tr
    image:
    PHP Code:
            <tr>
              <
    td valign=top><font face="Arial" size="2">myimage</font></td>
              <
    td>
      <
    img src=images/transparent.gif><br>
      
      <
    a href="javascript: MM_openBrWindow(
    'upload.php?id=23&f=myimage&mw=100&mh=100',
    'myimage','status=yes,menubar=yes,width=400,height=200')"
    >
      
    Upload Image
      
    </a>
    <
    br>
      <%
    myimage_remove%>
    </
    td
    To disable webmaster to upload image, you do not need to put image code as shown above.

  2. #2
    Join Date
    Aug 2003
    Posts
    233

    Default

    Hi,
    I made this change to msg.php and re-uploaded it :

    $msg["10143"] = "
    <a href=\"java script: MM_openBrWindow(
    'upload.php?id=<%link_id%>&f=<%field_name%>&mw=250 &mh=75',
    '<%field_name%>','status=yes,menubar=yes,width=255 ,height=75')\">
    Upload Image
    </a>
    ";


    But if you check here:

    http://atozfitness.com/indexu/browse.php?cat=145

    after I as admin uploaded a test image it can take an image any size.

    How do I fix this ?

    regards
    Lewis
    Best
    Lewis
    www.AtoZfitness.com/indexu

  3. #3
    Join Date
    Aug 2003
    Posts
    233

    Default

    has this problem been resolved by someone ?
    best
    Lewis
    Best
    Lewis
    www.AtoZfitness.com/indexu

Similar Threads

  1. Image upload
    By Hart_House in forum Tutorials, Hints & Tips
    Replies: 12
    Last Post: 11-12-2004, 03:02 PM
  2. Images for links ?
    By Rix in forum Pre-Sales Questions
    Replies: 6
    Last Post: 05-24-2004, 09:15 AM
  3. image not showing up after upload.
    By persut in forum v5.x
    Replies: 1
    Last Post: 03-03-2004, 07:11 PM
  4. Image upload problem
    By tariqali in forum v5.x
    Replies: 7
    Last Post: 07-13-2002, 09:14 AM
  5. Different Image ??
    By ideavirus in forum v3.2
    Replies: 0
    Last Post: 07-12-2002, 11:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •