Jump to content

adding a file to a directory


igpxnaruto4

Recommended Posts

If you're talking about saving a canvas image on the server, there's a discussion about that here: http://stackoverflow...age-on-a-server Renaming would involve something like this, in PHP:

$fname_orig = 'image.png';$fname = $fname_orig;$nr = 1;while (file_exists($fname)){  $chunks = explode('.', $fname_orig);  $chunks[count($chunks) - 2] .= $nr++;  $fname = implode('.', $chunks);} echo $fname;

Link to comment
Share on other sites

It's going to work to run that on jsfiddle or Dreamweaver, you need an actual PHP web server. The PHP code is only half of it, you also need the ajax code to send the image data to PHP. That's how the image data gets from Javascript to PHP. PHP gets the image data from Javascript and creates a file on the server.

Link to comment
Share on other sites

i really don't have much experience with this type of stuff. i was looking at

		    var url = canvas.toDataURL("image/png;base64;");		    downloadImage.attr('href', url);

of the js and was wuondering if changing this (downloadImage.attr('href', url); ) in any way could possibly make it generate the file?like for example downloadImage.attr('./gallery/gallery', url);or url.copy('./gallery/gallery');Thanks

Link to comment
Share on other sites

This line: downloadImage.attr('href', url); Sets the "href" attribute of the downloadImage element to the given URL. The downloadImage element is a link on the page. So if the URL says "test", then that line is the same as doing this: <a class="downloadimage" href="test"> So it doesn't make sense to do this: downloadImage.attr('./gallery/gallery', url); which would be the same as this: <a class="downloadimage" ./gallery/gallery="test"> It doesn't mean anything to do that, it's not a valid attribute for a link. Javascript cannot save files. If you want to save a file you have to use something other than Javascript. Javascript can get the data you want to save, but it needs to send it to something like a PHP script which can actually save a file. Javascript just runs in your web browser, it can't save a file on the server. It can't do anything with the server except send requests to it. PHP runs on the server, it can save files there.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...