Jump to content

Not able to upload image into correct folder


Skooly11

Recommended Posts

Just wondering if you can look at this code and help me out.

 

What I am doing is using Flash and php together. When you click on a button in Flash, it creates a folder on the our host server, gives it a random name, then copies another flash file into that folder. That part works fine. The next part enables a user to download an image into the new folder and give it a name (photo1.jpg). The only thing that doesn't work is that the new downloaded image is not saved into the newly created folder but in the folder above. For example, a new folder called "XYZ123" is created and it is saved here: testing/snowball/clients/XYZ123. But when the new image is downloaded it is not saved in "XYZ123" but in the "clients" folder. I have tried lots of things but still unable to download image into the newly created folder. Can you look at the code and see what's wrong.

 

 

<?php

ob_start();

$_SERVER['QUERY_STRING'];

 

//name of new  folder as created in Flash

$folderName = $_POST['folderName'];

 

//Path to where you want to create the new folder

$path = $_SERVER['DOCUMENT_ROOT']."/testing/snowball/clients/";

 

//Complete path to new folder

mkdir( $path . $folderName, 0777);

 

/Copies flash file into new folder

copy('testing/snowball.swf','testing/snowball/clients/'.$folderName .'/snowball.swf');

 

 

 

sleep(20);

 

if (is_uploaded_file($_FILES['Filedata']['tmp_name'])) {

//new name of image that is downloaded

$new_file_name="photo1.jpg";

 

 

//where to upload new image. This is where it seems to go wrong. Saves in clients folder instead of newly created folder

$uploadDirectory = 'testing/snowball/clients/'.$folderName .'/';

 

$uploadFile = $uploadDirectory . $new_file_name;

 

 

copy($_FILES['Filedata']['tmp_name'], $uploadFile);

 

 

}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.