iPhoneHTTPServer/CocoaHTTPServer File Uploads - javascript

I have managed to get the iPhoneHTTPServer sample within CocoaHTTPServer to work - I can display web pages, run JavaScript etc but what I cannot figure out is how to upload a file from my PC onto my iPhone.
I have looked at various JavaScript examples for "uploading files" but they appear only load files on the client side and don't actually upload files onto the server - ie - my iPhone.
Can somebody please provide me some example code that does this or some guidance as to how this is done?

OK! I found the SimpleFileUploadServer sample in the CocoaHTTPServer "Samples" folder.. I've been able to cut, paste and learn from that. All sorted.

Related

Why my changes are not displaying to the browser?

(this a long text but it's necessary for you to understand what I'm struggling with)
I've been trying to find a solution to this but I just couldn't find any info related to this so I wonder if it has to do something with my computer.
The problem is that when I am coding working on website in neither Sublime Text or VSC, (in the beginning everything was okay, I used to refresh the page or use a local server and my changes display on the Web page) any changes I make in the .html, .css or .js files don't show on the browser.
I tried closing and re-opening the text editor and the files, (that used to work at first) but now that doesn't work anymore, any simple change made after this "forzing" happens, just doesn't display on the browser. I tried also using opera, mozilla, chrome, and the problems persist.
I sent the files once to a friend of mine, he opened the .html file and my changes were working. He resend me the code after he used it, I pasted it (the same I sent him before that wasn't working) and then magically it worked!!!!
Now every time that happens I have to have Another personas computer to open the .html file, they resend it to me, I paste it again in order to make it work. This is so annoying and frustrating. If any of you could help me with anything to fix this, I'd very much appreciate it.
So in short, until some point my changes are displayed, but after that, the page stays the same as when it "freezes" and no matter which file I modify, the page just doesn't show changes after that freezing point
Thanks for your atttention
Since it doesn't work on a local computer, you can always use an online editor like Replit or CodePen (they worked quite well for me) ...
It could be that the files aren't correctly saved into your working directory. If you go into your terminal and navigate to the directory these files you're working on are in and type ls it will show all the files in this directory. If your files aren't there then you know you didn't save the files correctly into your working directory.

How to display a user-uploaded PDF in React using FilePicker from 'react-file-picker'?

My goal is to allow the user to upload a pdf from their file explorer, and upon clicking a button that says 'view', they'll be able to see that PDF file.
I'm currently using react-file-picker to upload files, but that doesn't seem to work.
I know someone is going to comment, "Look it up", or something like that, but I have. All the examples that I've seen so far are only tailored to PDFs that can be found at various online URLs. I'm obviously not using URLs, but instead actual pdfs from the users file explorer.
Currently I have a method for displaying the actual button to use when uploading files, and there's a method attached to it that handles the file after it's uploaded. I need help with the handleFileChange method below so that I can show the pdf. If 'FilePicker' isn't a good option, can anyone provide me with suggestions on good React tools that will help me achieve this?
Thanks for your help!
My code for uploading a file:
Check out the documentation for pdf-viewer-reactjs. It will do what you need and looks to be simple to implement.

File Upload/Manipulation/Download without use of a server: Is it possible?

I am looking to make a website that does three things:
The user can upload an image to the website (without a server)
-For this problem, I have found resources like Dropzone, but all seem to mandate sending the image to a server.
The uploaded file is manipulated on the client side
-For this problem, I need the uploaded file to be accessible from my JS/HTML code and I need some way for me to manipulate the file. I currently have my website with the pre-set file embedded in it, which I can then access and manipulate with JS, so the manipulation itself isn't much of the issue, but rather just accessing the file.
The user can then download the manipulated file (again, without a server)
-For this problem, I know that how to make a download button for files that have a web address (which are on a server), but is there a way to have a download button for the file that was just manipulated? I found this question here that seems to be a good starting point, but I am not sure if I completely understand the implementation of it.
Basically, I have the website framework in place (using HTML/CSS, Javascript) and I am just looking to see if this is possible to do without the use of a server, even if I have to use some other libraries. If any insight or links to potentially useful articles/libraries could be given on any one of these three points, I would much appreciate it.
Note: If this is not possible without a server, please let me know because then I will have to completely redesign everything and this whole question is trivial.
The user can upload an image to the website (without a server)
A website is typically hosted on a server. I think you mean the image is uploaded, but not stored anywhere.
The uploaded file is manipulated on the client side
There are lots of cool JS libraries to handle this, for something light you can try out https://fengyuanchen.github.io/cropperjs/
The user can then download the manipulated file (again, without a server)
So if I am understanding you are asking for an image upload -> edit -> image download. This is very possible and common. However, you will need somewhere to cache the uploaded image for the client.
If you are asking if you can upload an image directly to the DOM, you can not. You need to upload the image to the location where your files are being hosted. Imagine having an absolute path to C:/MyComputer/MyImage, it would obviously not work on any other machine than your machine.
If you need some examples on how to handle the upload image to temp location -> edit -> download let me know

PebbleKit JavaScript send image to Pebble

Is it possible to send a images to the Pebble watch using PebbleKit Javascript sendAppMessage.
My idea is to load an image from the web and send it to the watch and display them there. If an image is not possible directly then I was thinking of drawing the image to a canvas and trying to get bitmap data from the canvas to send to the watch.
Is any of this possible now or am I thinking of things that have not been done yet. If possible how? If not done yet how might you do it?
Looking to brainstorm and share possible code ideas.
I should also mention that I do not want to use an iOS or Android app, only the PebbleKit JS.
There is a complete example of an app that uses JavaScript to download images in the pebble-hacks Github repository. This github projects hosts different non-official yet written by team pebble.
The one you are looking for is pebble-faces. The image download part is built in a separate source file to be easily re-used in your own project.
I also added a PHP port for the Python script here
https://github.com/logbon72/pebblebitmap
It might come in handy if your run PHP applications that need to do conversion on the fly.

How can I let users upload files by copy/paste?

I'm trying to create a web app based on ExtJS, and I'm working on the file-upload area of the app.
I want users to be able to upload files by copying and pasting them - not just copying and pasting the contents of the file, but the file itself. For example, in Windows, you can choose "Copy" or "Cut" from the Edit menu while a file is selected, then choose "Paste" later and copy or move the file - I'd like users to be able to upload files to my app in the Paste step, by just choosing Paste in their browser.
I've already tried HTML5's drag-and-drop API, but we don't want to use that - we want users to be able to copy/cut and paste files to upload their files (as long as they're smaller than 20 megabytes). If the user copies the path to their file and pastes that directly to the page, telling us where to find the file, that could also work.
Can anyone suggest a way to do this?
The thing is, that you're not able to access the clients filesystem with javascript. There is this new Filesystem API, but this just allows you to create a virtual sandboxed filesystem. I had the same problem, thought about it a while and came up with the following ideas.
Flash
Writing a Flash bridge which access the filesystem and let the javascript communicate with it via swliveconnect
Problem: Flash doesn't have filesystem access either.
Java applet
Same thing as Flash and again with LiveConnect
In my opinion this could work, but I didn't try it out, because my goal was to get filesystem access on a chromebook. And chromeOS doesn't support Java (at least without some hacking)
ActiveX
I also found some solutions with this. I gave up at the applet part so I didn't try this out either.
As Jared Farrish said, when you copy a file the os just saves the path to the file in the clipboard. Then if you receive the paste event on your webapp just get the string out of the clipboard and forward it to your file bridge.
I've seen that DropBox.com allows this to be done (in chrome- didn't seem to work in IE). I didn't do cut and paste specifically, but dragged files into a dropbox page from a local folder, and it uploaded the files. So, this doesnt directly answer your quesiton, but perhaps you can look at how this is done in their code.

Categories

Resources