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
It will run javascript called MM_openBrWindow (the code is in modify_form.html). It will open new window with:Code:javascript: MM_openBrWindow('upload.php?id=29&f=myimage&mw=100&mh=100', 'myimage','status=yes,menubar=yes,width=400, height=200')
- 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
Just change mw and mh to any number as you wish.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>
";
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:
multiline 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>
image: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>
To disable webmaster to upload image, you do not need to put image code as shown above.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>


