Hands-on: Acer Predator Triton 700 review
I am writing my own content management system for my website. I've got a script which uploads images - that's fine. For each article, I want an image associated with it. I want to either enter the filename of the image in a text box on a form or select it from the uploaded images. I wrote a script that displays all the uploaded images but now I can't figure out how to write the script to fill the text box with the image name. Next to the text box I have a link called Browse which opens a page in a new window with all the uploaded pictures in. What I need to know is what the script would be that means when an image is clicked, the address of that image is entered into the text box on the form in the other window. I have the url of the image in a variable on the PHP page called $url.
Any help is appreciated. Thanks
<input type="button" Value="NAME" style="font-family:verdana" style="color:ffffff" style="background:#ff0033" style="font-size: 14pt" ONCLICK="window.open('click here URL YOU WANT THE BUTTON TO GO TO')">
change the word name with your page name then put in the url to the page you want the link to goto ..hope this is what you ment
Several things spring to mind here. The first is, do you really want the address of the image entered into the text box ? One of the joys of scripting a CMS is that you get to hide the filepath of images or downloads which can help prevent leeching.
The way I normally do this is to write an upload script that renames the file when the file reaches the web server, then the filename is recorded into the MySQL database. Renaming is usually only necessary where many images need to be managed from specific sources. If you don't need a rename function, don't use it. I only use MySQL to store images if there are very few, but if there are loads I store the filename and path. The browse function pulls the filename from the database and a request to view the image pulls the image into the browser by calling its path. I tend to use $img_src for the filename and $img_alt for the ALT descriptive tag, both pulled out of the database using SQL.
You seem to have a lot of ideas and I wish you every success with them. I wonder though, if you have a firm plan of what goes where, when and why. A CMS is, by its very nature, no small undertaking and if you want an image to accompany an article I can see several golden opportunities for document linking, logical filename structures and so on.
My largely unhelpful reply in this case is to sit back, stop coding, get a pen and paper and plan in minute detail what you want. If you get the planning all thoroughly prepared with a system specification, design brief, data flow diagrams and so on, the coding becomes naturally easier since you have a model to work to. I may be doing you an injustice - perhaps you have already done that and you are merely struggling with the actual code for certain functions.
This thread is now locked and can not be replied to.