[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Hey /g/ I need to make a page on my site that will allow use
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 29
Thread images: 4
File: 1457542178588.png (2 MB, 960x1280) Image search: [Google]
1457542178588.png
2 MB, 960x1280
Hey /g/
I need to make a page on my site that will allow users to make a folder on the site of their choice, for example entering "test" will make the folder http://localhost/test and also copy all the files from http://localhost/data to the new folder and redirect the user to the newly created folder on the server. How can I do this?
>>
Use the filesystem api from your programming language of preference.
>>
>>53472356
I'm horrible at coding. How would this be done in php? Possibly html if thats even possible?
>>
>>53472454
>I'm horrible at coding. How would this be done in php?
well, first you would have to learn php
>>
>>53472979
or possibly html if that's even possible
>>
>>53472317
if it has to be with php then you might need to execute shell commands through php with exec().

if you must do it that way, remember to escape your exec() commands, and that you need to put your web server user, usually something like "www-data" or "srv", in the sudoers list for any executables you have to run.

don't take my word for it though, this isn't the safest of methods and someone who actually knows php might know a better way.
>>
>>53472454
Step 1: read this
http://php.net/manual/en/ref.filesystem.php

Step 2: write code
>>
File: code.png (41 KB, 881x691) Image search: [Google]
code.png
41 KB, 881x691
So I got this far...
Why isn't the copying part of the code working?
Did I make an error?
>>
File: middle-finger-jonny-doomsda.jpg (38 KB, 500x500) Image search: [Google]
middle-finger-jonny-doomsda.jpg
38 KB, 500x500
I'm a PHP developer.

I would probably just go to Google and enter "PHP copy folder" and click the first Stack Exchange link, and then read the words on my screen until I had a pretty good understanding of what they said. Then I would use that knowledge to create a PHP backend that copies data from one preexisting folder to another.

Then, I would do the same thing that I just did, but instead I would Google "PHP create folder" and use THAT code to make a folder before copying the data.

THEN, I would use HTML to make a form with only one field, foldername, and a submit button, and use either POST or GET methods to extract the data from the form to the PHP function that would make a folder using the name entered in the form, then copy the data.

Literally, work backwards.

Literally, learn how to fucking Google.

You aren't bad at coding, you just want us to do it for you because you're bad at paying attention.
>>
>>53474611
Also, just so we're clear, you don't need to execute any shell functions. PHP has enough in its codebase to do all of this shit for you, and it isn't even complicated.
>>
Am I the only one who doesn't understand what the hell OP is trying to accomplish?

If the contents of ‘test’ and the contents of ‘data’ are the same, then why not just rewrite the URL? Huh?
>>
>>53474685
They want the user to be approached with a form where they can enter the name of a folder they'd like to create. The software will create a folder in its root of that name, and copy the contents on another folder, in this case 'data', to the newly created user folder, and then redirect them there. OP also made strong suggestion that this would be browser-based, meaning ASP.NET or PHP.

It's really simple, actually.
>>
>>53474708
You've just paraphrased the OP's post but you haven't explained to me what OP is actually trying to accomplish.

HTTP doesn't have a concept of ‘folders’. You're looking at the wrong abstraction.

From the point of view of a user, how exactly is the web server supposed to reply to requests?
>>
>>53474838
What are you talking about dude? From the point of view of the user, they type the name of a folder they'd like to create, and then in a second or two they're there. A brand new folder.

I keep re-reading your post, but I don't follow what you're trying to get at.
>>
>>53474877
So I go on OP's shitty website at say http://blackchickswithdicks.com/test

What do I see? A blank page?
>>
>>53474894
As described in the OP, it will copy the contents of folder A into the newly created folder B so when you go to it, you'll get those contents.

Regarding use, this could be for copying an unmodified version of script, prior to any customization that could be done in an editor, for example. It could be used for backing up files such as images. There are numerous reasons this could be used.
>>
Source on the semen demon?
>>
>>53474927
that's fucking retarded then, just use a symlink or a redirect rule
>>
File: 1457905608167.png (2 MB, 960x1280) Image search: [Google]
1457905608167.png
2 MB, 960x1280
>>53472317

that white balance is triggering my autism
>>
>>53474927
>As described in the OP, it will copy the contents of folder A into the newly created folder B so when you go to it, you'll get those contents.
So no matter what URL you load, you always just see the same contents?

That's easy as piss, redirect every URL to the same static file.
>>
>>53474961
still looks off desu
>>
>>53474950
Hi, my name's anon and I'm so focused on whether or not the application is useful to me as an individual, I'm not going to think about if it can even be done.

Just chill the fuck out. It's entirely possible that OP doesn't want people in the source folder.

>>53474970
Again, OP may not want people in the source folder for whatever reason. It could be that it's protected. It could be that the client needs a version that's missing certain files.

Yes, there are probably more efficient ways to handle this task. But without knowing the use-case and application, the answer is yes, it's achievable, and no, you don't need anything special to do it.
>>
>>53474993
>Yes, there are probably more efficient ways to handle this task. But without knowing the use-case and application, the answer is yes, it's achievable, and no, you don't need anything special to do it.
It just stinks of using a hammer to drive in a screw.
>>
>>53475032
It's probably some shitty assignment for class. They're using nano to edit PHP files, which isn't what I would call efficient.
>>
>>53472317
What have you tried doing OP?
What part are you stuck on?
Have you used a search engine?
>>
>>53475046
What do you mean? Nano is a terminal program. That's some low level genius shit.
>>
>>53475248
>being this new
Just keep using your nano thinking it makes you look cool or something.
>>
I think this is what OP's looking for
too bad I wrote it in python because PHP is gay :^)
import os.path
from flask import Flask, request
from flask.ext.autoindex import AutoIndex
from distutils.dir_util import copy_tree

app = Flask(__name__)
ai = AutoIndex(app, os.path.curdir, add_url_rules=False)

html = """\
<form method="post" action="#">
<input type="text" name="foldername">
<input type="submit" name="submit" value="Create Folder">\
"""

@app.route('/', methods=['GET', 'POST'])
def home():
if request.method == 'POST':
copy_tree('Pictures', request.form['foldername'])
return html


@app.route('/<path>')
def autoindex(path):
return ai.render_autoindex(path)


if __name__ == '__main__':
app.run()
>>
>>53474947
Chesqin and Monimusume
Thread replies: 29
Thread images: 4

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.