phppup Posted October 30, 2019 Share Posted October 30, 2019 It always seems so simple.... LOL Hello to my old friends, I have been toying with adding an UPLOAD SCRIPT for moving images from a desktop to a website in order to eliminate the need to log into the server to post images. I've seen a few online scripts of various degrees and some with demos), yet the one blaring question remains: Where is the line that dictates where the files end up? So many of the scripts explain how wonderfully they look and operate, but they do not indicate where to edit in order to control the endpoint. Any insight, as well as guidance to avoid pitfalls with regard to this venture will be appreciated. Happy Halloween, as if coding isn't scary enough (at times). *wink* Quote Link to comment https://forums.phpfreaks.com/topic/309435-dgar-and-drop-upload-script/ Share on other sites More sharing options...
requinix Posted October 30, 2019 Share Posted October 30, 2019 4 hours ago, phppup said: I've seen a few online scripts of various degrees and some with demos), yet the one blaring question remains: Where is the line that dictates where the files end up? Exactly what kind of answer are you looking for? How can anyone reply to that question in a way that doesn't make the answer sound obvious? Quote Link to comment https://forums.phpfreaks.com/topic/309435-dgar-and-drop-upload-script/#findComment-1571109 Share on other sites More sharing options...
phppup Posted October 30, 2019 Author Share Posted October 30, 2019 An obvious answer would be ok. Sometimes the most difficult solutions are in plain sight. I am not doing the images in a database, so I am looking at JS scripting. I want sure if the destination folder is required to be at the top of a script, or file some specific guidelines. I'm sure I'll eventually find the answer, but I was hoping for a clue that might help me save some time. Quote Link to comment https://forums.phpfreaks.com/topic/309435-dgar-and-drop-upload-script/#findComment-1571113 Share on other sites More sharing options...
requinix Posted October 30, 2019 Share Posted October 30, 2019 3 minutes ago, phppup said: An obvious answer would be ok. Then the answer to "where is the line I need to edit" is either "whatever the code says the line is" or "whatever the documentation says the line is". In other words, 3 minutes ago, phppup said: I am not doing the images in a database, so I am looking at JS scripting. I don't see what one has to do with the other. 3 minutes ago, phppup said: I want sure if the destination folder is required to be at the top of a script, or file some specific guidelines. Javascript cannot upload files to a directory on your server. Thankfully. You have to have an script to receive uploaded files and process them according to however you want. Quote Link to comment https://forums.phpfreaks.com/topic/309435-dgar-and-drop-upload-script/#findComment-1571114 Share on other sites More sharing options...
phppup Posted October 30, 2019 Author Share Posted October 30, 2019 Are you saying that even if the JavaScript is on the server, it will not be able to put the image files on the same server? Quote Link to comment https://forums.phpfreaks.com/topic/309435-dgar-and-drop-upload-script/#findComment-1571116 Share on other sites More sharing options...
requinix Posted October 30, 2019 Share Posted October 30, 2019 Yeah. Javascript runs on the browser. Not the server. (Except like Node.js, that's different.) And it would be an extremely terrible idea to allow Javascript on someone's browser to upload files to your server without your say-so. Quote Link to comment https://forums.phpfreaks.com/topic/309435-dgar-and-drop-upload-script/#findComment-1571117 Share on other sites More sharing options...
phppup Posted October 30, 2019 Author Share Posted October 30, 2019 So a decent script would include a php file that connects to the server, and validates the file type or 'scrubs it' for security purposes? Quote Link to comment https://forums.phpfreaks.com/topic/309435-dgar-and-drop-upload-script/#findComment-1571122 Share on other sites More sharing options...
requinix Posted October 30, 2019 Share Posted October 30, 2019 No, because a decent "script" doesn't know you or your application or your server. Perish the thought but you have to actually do some work here. Quote Link to comment https://forums.phpfreaks.com/topic/309435-dgar-and-drop-upload-script/#findComment-1571123 Share on other sites More sharing options...
phppup Posted October 30, 2019 Author Share Posted October 30, 2019 That's exactly what I was trying to avoid. LoL. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/309435-dgar-and-drop-upload-script/#findComment-1571124 Share on other sites More sharing options...
dalecosp Posted October 31, 2019 Share Posted October 31, 2019 Drag 'n drop is done with an AJAX system; a JavaScript front-end script packages the image data into a FormData object, and the AJAX operation will POST that to a PHP handler script on the server, which then does the work to put it someplace just like we did in the Elder Days when we used a basic upload form in HTML. So, at the very least you need two scripts, one PHP and one in JS. Quote Link to comment https://forums.phpfreaks.com/topic/309435-dgar-and-drop-upload-script/#findComment-1571134 Share on other sites More sharing options...
phppup Posted November 20, 2019 Author Share Posted November 20, 2019 (edited) After a lot of reading and some progress, there are now a whole new set of questions that have emerged. So this thread requires more discussion and opinion for guidance, rather than actual code solutions. I have found different approaches to uploading image files. Some upload directly to a destination folder. Some upload to a database. Some do both. It seems more practical to upload image files to a folder (although I do recognize the bonus of having information about the individual files stored for reference), but is there a benefit to using one instead of the other? For space? Speed? Other implementations? Edited November 20, 2019 by phppup Quote Link to comment https://forums.phpfreaks.com/topic/309435-dgar-and-drop-upload-script/#findComment-1571729 Share on other sites More sharing options...
requinix Posted November 20, 2019 Share Posted November 20, 2019 6 hours ago, phppup said: I have found different approaches to uploading image files. Some upload directly to a destination folder. Some upload to a database. Some do both. Correction: some upload to a server-side script that then places the file in a destination folder, and some upload to a server-side script that then places the file into a database. 6 hours ago, phppup said: It seems more practical to upload image files to a folder (although I do recognize the bonus of having information about the individual files stored for reference), but is there a benefit to using one instead of the other? For space? Speed? Other implementations? If you only have one server then store in a folder. It's just easier to work with. If you have multiple servers and a shared storage space then I personally would still store as a file, and if not then use the database. Quote Link to comment https://forums.phpfreaks.com/topic/309435-dgar-and-drop-upload-script/#findComment-1571747 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.