Karaethon Posted December 20, 2018 Share Posted December 20, 2018 I am trying to write a phone script that will accept a file uploaded by a user, read and alter the file byte by byte then return the file to the user. The class that alters the file I have already written but I don't know how to accept the uploaded file data, how to read it byte by byte, what to do with the altered data until the file alteration is complete, and how to return it to the user. Any help would be greatly appreciated. Quote Link to comment Share on other sites More sharing options...
benanamen Posted December 20, 2018 Share Posted December 20, 2018 Tell tell us about the real problem at hand instead of telling us how you're attempting to solve the real problem. Quote Link to comment Share on other sites More sharing options...
Karaethon Posted December 20, 2018 Author Share Posted December 20, 2018 The real problem is I don't know what the uploaded data looks like on the server side, I don't know what commands PHP has to allow me to read the file data so I can alter it, and I don't know how to store/compile the altered data until I return it to the user. Since I don't know this stuff I can't figure out how to write an interface between the user and the class that alters the data. Quote Link to comment Share on other sites More sharing options...
maxxd Posted December 20, 2018 Share Posted December 20, 2018 What kind of data are you expecting to work with? PHP can work with image, text, JSON, XML, PDF, and many other types of data but it's all done differently. So, what are you actually trying to accomplish other than altering user-supplied data? Quote Link to comment Share on other sites More sharing options...
requinix Posted December 20, 2018 Share Posted December 20, 2018 I think I'm going to take the surprisingly unpopular standpoint that you know more about what you're working with than we do, so 1 hour ago, Karaethon said: I don't know how to accept the uploaded file data, how to read it byte by byte, what to do with the altered data until the file alteration is complete, and how to return it to the user. Accept the file upload using the normal method. PHP will create a temporary file on the server which you can read using functions like fopen, fread, and fclose. Kind of an open question about exactly how you intend to "alter" the data... You can return it to the user with a download prompt: header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename=" . $filename); /* output file here */ exit; Quote Link to comment Share on other sites More sharing options...
Karaethon Posted December 20, 2018 Author Share Posted December 20, 2018 Ok. Maxxd, I will accept any file type the user submits, the alteration is an encryption algorithm based upon a multi-step pivoting value and a continuouly morphing key, so any file the user supplies (within size limits set by PHP/server) will be accepted and altered. Requinix, thank you for pointing me in the (hopefully) right direction. Quote Link to comment Share on other sites More sharing options...
Karaethon Posted December 20, 2018 Author Share Posted December 20, 2018 2 hours ago, Karaethon said: ...to write a phone script that will accept a file uploaded by... arghh just caught that autocorrect changed PHP to phone in my initial post! I hate autocorrect sometimes. Quote Link to comment Share on other sites More sharing options...
requinix Posted December 20, 2018 Share Posted December 20, 2018 38 minutes ago, Karaethon said: the alteration is an encryption algorithm based upon a multi-step pivoting value and a continuouly morphing key, so any file the user supplies (within size limits set by PHP/server) will be accepted and altered. Block cipher? fopen + fread blocks of whatever size until you reach the end + fclose. If you use the r+ file opening mode then you can read the blocks and write the encrypted output back to it. readfile can output the file (alternatively fseek() to 0 and fpassthru()), and when your script ends PHP will clean up the file for you since you were using the temporary file it had created. Quote Link to comment Share on other sites More sharing options...
Karaethon Posted December 20, 2018 Author Share Posted December 20, 2018 Sweet, so I don't need to store a pre and post crypt version. Saves on space. Woohoo. Quote Link to comment Share on other sites More sharing options...
benanamen Posted December 20, 2018 Share Posted December 20, 2018 You still you still haven't told us what your really trying to do. What is the point of all this code? Quote Link to comment Share on other sites More sharing options...
requinix Posted December 20, 2018 Share Posted December 20, 2018 1 minute ago, benanamen said: You still you still haven't told us what your really trying to do. What is the point of all this code? What do you think? Quote Link to comment Share on other sites More sharing options...
benanamen Posted December 20, 2018 Share Posted December 20, 2018 3 hours ago, requinix said: What do you think? Best I can tell is it is some kind of homemade file encrypter. Quote Link to comment Share on other sites More sharing options...
Karaethon Posted December 20, 2018 Author Share Posted December 20, 2018 1 hour ago, benanamen said: Best I can tell is it is some kind of homemade file encrypter. Yes, I spent from 2010 to 2016 designing, writing, testing, and attempting to hack a new algorithm that does not rely on prime numbers and that would be resistant to quantum computing's ability to express multiple states at the same time. After being satisfied that it met my requirements I have been polishing the functionality and now I am ready to begin beta testing it so I wanted to put an essential version of it on my site for the beta testers to play with and find anything I might have missed. Quote Link to comment Share on other sites More sharing options...
benanamen Posted December 20, 2018 Share Posted December 20, 2018 (edited) 10 minutes ago, Karaethon said: I wanted to put an essential version of it on my site for the beta testers to play with and find anything I might have missed. The best way to find out if you "missed" anything is to post your code on a repo for peer review. Based on the questions you have been asking I would personally have to question your ability to write a secure encryption algorithm which is no small task, but then you could be a wizard mathematician for all I know. Best thing is to show us the code. EDIT: Nothing personal by the way Edited December 20, 2018 by benanamen Quote Link to comment Share on other sites More sharing options...
Karaethon Posted December 20, 2018 Author Share Posted December 20, 2018 (edited) No offense taken. I am fluent in some languages, mostly basic variants and such, but I have no experience with PHP so I don't know what it can do or how to do things I know how you feel do in basic. And I'm not looking for what I missed in the code, I'm looking for what I missed in the design, I tested every way I could think of but I know that doesn't mean I thought of everything so my beta testers will hopefully find anything I missed. Edit: and yes, mathematics is my playground when I'm bored. I try to solve new unsolvables when I can't find anything to occupy my time. Edited December 21, 2018 by Karaethon Forgot to include Quote Link to comment Share on other sites More sharing options...
benanamen Posted December 21, 2018 Share Posted December 21, 2018 2 minutes ago, Karaethon said: I'm not looking for what I missed in the code You VERY MUCH should be! Anyways, I am sure you have learned things in your quest which is always a good thing and you can't knock a guy for trying. You have to start somewhere. By the way, your response a couple posts back was what I was trying to get at when I was asking what you are really doing instead of how you are trying to do it. It is much better for us to know that as the opener so we can properly respond to you. Quote Link to comment 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.