Open MS Word from website - php

I have a website in which user has ability to upload his documents in MS word, Power point and pdf types. Now what i want is that if user clicks a certain button or link, a new Word document opens up where he can create a new document and upload it on my website. How can i do that is there any way where it can be done on single click?

I think the simple or short solution would be to allow them to upload files, and limit to filetypes that you specify, and then have an alternative option for simply typing it into their browser like TinyMCE Or something like that.
At best you could maybe launch word, sort of like how apple itunes can be launched from the apple website, but there would be no way for them to save without uploading it the server, in which then again you would want a series of validators to make sure they aren't uploading malicious files.

Related

Make HTML code show all pictures in a folder from FTP?

basic html code user here, just trying to get some scripts finished up and im struggling.
I have a hosted website, and a hosted dedicated server. I have a folder on my dedicated server full of pictures (screenshots) from server players that gets taken randomly. Its for anti cheat.
Basically, ive been trying to write a script so that on a webpage on my hosted website, it automatically shows all the pictures from that folder on my dedi.
Im struggling.
The only code i know to show a picture from ftp is
img src="ftp://username:password#my_ftp_ip_address/Images/imagename.jpg"
I want to create something that automatically shows all the pictures or at least lists the folder directory so that i can click on the pictures, but im a bit confused on how to do this! Any help would be great thanks!
This is basically an anti-pattern. You shouldn't be exposing your username and password in your HTML code.
One thing you can do, is set up a web server on your FTP server so instead of <img src="ftp://..." /> you'll be using <img src="https://my-server.com/image.jpg" />
For example you can set up nginx or apache to serve the images from a certain directory but prevent directory listings.
For nginx, you can either follow the official docs, or get a hint from this SO Question
Same thing with apache, you can pick whichever you find that fits your needs best.
With using <img src""></img> you can target the folder directly without having to insert a link. Like so: <img src"<folder holding images>/<image name>" /> this should target the photo you are looking for without having to expose your username, password, and FTP information.
If you want to show all images it needs to be defined in your HTML, you need to use the code above to target each image individually (Helps organization).
If you want to be able to click on the photos you can add and that should allow you to click on the image and then open it in a bigger version. If you want to make it open in a new tab add this target="_blank" to your <a></a> tag so that way it opens in a new tab.

Secure files and display them as well

My question is about HTML and PHP.
This is my setup right now:
A website where user have accounts
A FTP server with pictures (currently none)
Files are currently saved on the website in the "PICTURES" folder (which is accessible by everybody who know the full URL)
So, I would like to know how I can display the images without storing them on the website (which will fix my URL problem).
My idea was to move the files on the FTP server, and when a users logon and request a page with those images, download them through a FTP connection, save them on the website, display the images, and remove them. Which would make them accessible only between the downloading time. But this solutions sounds REALLY bad to me.
You need always to have a place where your images are stored. But, if you don't want to give a user the chance to know where are stored, you can create a system which is used to show the images.
Think about this, if you want to download a file from Mega, you can't access to the URL where the file is stored, instead of that, the server itselfs calls a system who assign you a "key" and you can download the file only through that system using your "key".
You could use a system like "base64" so you can encode your image, and show it using it, or, you can use the "header" modifier so, you can display an image using a PHP code.
For example your image tag will be like:
<img src="processImage.php?id=01&user=10&key=123" />
So, your processImage will return a "tricky" image, actually not the image, but the code processed by PHP will be returned, like using "imagejpg()" function with the header "Content-Type:image/jpeg" and then the user will not know where the image is stored actually but the img will works actually.

How to display image preview without downloading from given url using PHP?

So I'm working on a project to fetch images from fashion websites. Now I'm implementing the add item function in the website. In this function, user needs to input website url first, then the web scraper will scrape the target images' url and pass the urls to the curl to download the image. Finally the add item popup window will preview the images I fetched in the previous step and ask the user to fill out some basic information for the items. Everything works fine except that the curl will take a very long time to download the images (cuz the images from those fashion website are often very high-quality). So I'm wondering is there a way I can create a preview without actually downloading the full-size images and do the download when the user fill out basic information later. Thanks!
If the fashion website has smaller versions of the images, you should download those first. You can use them for your preview.
If the fashion website only has the full size image, there is no way to download a smaller version of it.
You probably know what your doing, but remember that you should respect the copyright of images on websites, especially art websites such as fashion websites. Be careful with what you do with them.

Upload multiple files while navigating other pages - howto?

I'm creating a website and I'd like to allow users to upload multiple files while they navigate the website.
When the upload completes, it would be nice to have a Javascipt event triggered, to allow the user to specify additional info related to the uploaded files (eg. photo location, tags, etc)
anyway, the required features are:
multiple files allowed for a single upload operation
display an optional progress indicator (at least in the "x of y files uploaded" fashion)
doing it without tying the users to a single page
How can I implement these features?
Any suggestion is greatly appreciated!
Edit
In the event of using a popup window to handle uploads, how can I:
inform the user (on the "master" page) that the upload has completed, or that there have been errors?
(more important) pass the $_FILES array to the popup window? I'd like the user to be able to click "upload" on the main window, or anyway to make the upload start from the main window (eg dragging and dropping files on the main window).
Since navigating the site will switch pages and it's unlikely that there's a full ajax navigation on your site, maybe it could help to somehow upload the files in a second popup window. Not sure how (if) it could be implemented, though, but since you need to upload multiple files at a time I'm afraid you're bound to use flash.
EDIT
So the solution could look like this:
When a user clicks a "select files" button you pop out a new window where he'll be able to actually select files (via flash if multifile upload is necessary). And to notify of upload progress use postMessage. Though postMessage isn't going to work in IE in this case, but probably you could somehow send the message to the server and from the server back to the page.
Another crazy idea is not to use a popup window, but let the user select the files on the page she was first, but once the user selects the files make all the links on the page target=_blank to make any subsequent navigation happen in another tab. I know it's hacky and not exactly user-friendly, but probably could help.
In any case I would inform the user beforehand that a new window will appear in both scenarios.
EDIT2
And an even crazier idea. When the user selects the files and clicks a link create an iframe which will cover the whole page and hide the original page beneath it and make the links open in the iframe. But it looks even more hackish and it seems you'll have much trouble with it.

How to implement a Rich Text Editor with uploadable images anywhere inside text

I would like to implement a RTE (Rich Text Editor) with the ability to upload images anywhere inside the text. My aim is to create an "add / edit news article" page, where the client can write a story with images.
I am good at PHP and Javascript programming, so I am looking for help about methods of implementing this. Do I create a custom button in this RTE to insert a previously uploaded image or some other way? How do I display those images for the user to choose? Etc.
Bonus points for:
Multiple files upload: the ability for the client to just select e.g. 10 images that are relevant to this story.
Uses some method other than Flash as a default for upload.
Uses jQuery as I use it a lot.
RTE is very lightweight. I don't care if the client has to know a few things (like markdown or something similar), I just don't like bloated RTEs.
Uses new technologies, like HTML5 and / or CSS3.
Let me clarify a few things. I know a few Javascript RTEs and have also used them in several CMSs. So I don't need links to these, I can Google "javascript RTE" myself :). However, something like #hakre said is useful as he pointed out how extensible CKEditor is, which I was not fully aware.
To give an example of the answer I'm looking for: "you can do this with CKEditor, upload images asynchronously with jquery-html5-upload, save all uploaded image filename in a Javascript array, create a new button inside CKEditor with a custom click handler, which displays an overlay with Fancybox and you show all the images (you have filenames stored in an array), user clicks an image and you insert html into the editor".
Something like that but better :) (or should I say accurate).
Anything in here that meets with your reqs? http://ckeditor.com/developer-features
You taken a look at TinyMCEor CKEditor?
The "fake answer" you gave yourself is quite accurate. You would need a RTE editor that supports custom functionality.
The logistics would go along these lines:
User presses a button
An empty div is appended to the input with a unique id
An image uploader popup will open, with pointers to the new div
A combination of jQuery / AJAX / PHP will allow the user to upload a file within the page
The filename is returned after the upload process and inserted in the originally appended div
If you are looking for the specific code for each of these steps, I would recommend finding some tutorials as this isn't something that we can write some fast example code for.

Categories