Jump to content

WTF? I feel like everything in my life hinges on this simple concept.


sharpmac

Recommended Posts

$dir = $_REQUEST["imageDir"];
move_uploaded_file($_FILES['Filedata']['tmp_name'], $dir.="/".$_FILES['Filedata']['name']);

Doesn't work

 

 

$dir = "test";
move_uploaded_file($_FILES['Filedata']['tmp_name'], $dir.="/".$_FILES['Filedata']['name']);

WORKS..... WHAT IS GOING ON?

 

I mostly am bashing my head into a wall because it works with a static variable, but not one that is pulled in from ANYWHERE! I tried _GET, _POST, _REQUEST I even tried saving the variable in a xml file, and getting it to read it from the node.

 

This has to be my own frustration making me over look the simplicity of my error.

 

I am grateful for any feedback.

 

I wouldn't concatenate inside the function, personally.  Also, stick with _GET or _POST as _REQUEST is depreciated.

 

$dir = $_GET['imageDir'];
move_uploaded_file($_FILES['Filedata']['tmp_name'], $dir . "/" . $_FILES['Filedata']['name']);

 

Maybe that changes something?  (no .=)

move_uploaded_file

 

$filename = $_FILES['Filedata']['tmp_name'];
$destination = $_GET['imageDir'] . '/' . $_FILES['Filedata']['name'];

move_uploaded_file($filename, $destination);

Try that, the issue may have been me using "/" instead of '/'.  Check to make sure your input variables ($_GET['imageDir'], and $_FILES['Filedata']['name']) are working as expected if that doesn't work.

I couldn't find my source for this after a few mins of googling..

 

However, when you have $_POST and $_GET, you should more often than not know what to expect rather than be "flexible" with it.  Perhaps someone else can chime in on this, but I'm fairly certain it is bad practice to use $_REQUEST in general.

I tested out the new code, the form is pulling it down properly and it is adding the / at the end of the variable. But it is simply refusing to place the images in that freaking directory.

 

I have attached the zip file, there are four main files being used.

 

adm_gallery.php

processes he form, gets the data and makes the directory as well as edits various files used in the gallery script.

 

upload.php

this is where the flash file calls to in order to take the temp files and move them to the specified directory

 

settings.xml

this file holds the variables that flash uses to pull from, it's only real function is style and to point to the "upload.php" file.

 

Uploader.as

AS3 code compiling the flash application and naming variables used throughout.

 

 

Run index.html I filled in the requirements already so just hit submit, the script will make 1 folder and 1 file. Folder "test" and file 9999999.xml.  The xml file the script makes is only for the gallery viewer it is not needed to make the uploaded function.

 

Anyways I am sure all of you are more then able to figure out how the rest of it works... if you have any suggestions i would love to hear them.

 

[attachment deleted by admin]

I have tried the script many times  _GET does not echo, but _POST does.

 

I am wondering if this is a glitch or something within php..... it does not make any since to that it will pass a static variable vs a _GET or _POST

I tested out the new code, the form is pulling it down properly and it is adding the / at the end of the variable. But it is simply refusing to place the images in that freaking directory.

 

If the path is correct, check the permission on the directory.  The server needs to be able to write to it either by owning the directory or CHMOD needs to be set to 777

If the path is correct, check the permission on the directory.  The server needs to be able to write to it either by owning the directory or CHMOD needs to be set to 777

 

CHMOD is not the issue, it is running off of local host of my windows xp desktop. Even if it was CHMOD, why would $dir = "test"; WORK and $dir = $_GET['imageDir']; NOT?

I suggest you review your understanding of $_GET AND $_POST tags. get tags are used in the url, while post tags are from a form.

 

http://www.tizag.com/phpT/postget.php

 

I have tried the code many ways, re-written the form to process via get and post. Weather its in the URL, or posted in the session it doesn't matter.

 

It simply will not use $dir unless it is a STATIC variable.

 

And I'm lost as to why.

Well, the fact that the uploading tool is a flash file makes it hard for us to help. Can I see the actionscript for the upload button on the flash file? EDIT: Never mind. I'll look through the AS.

 

Ok. The directory is being created in my case and no file is being created, but I can't see how you are even requesting the directory name variable. I'm kind of lost in this case. Sorry.

In the form for _POST, I also try to pass in the variable "test". Once I submit the form the echo does read "test/", it echo's correctly when it is static variable or not. The only difference is when the variable is coming from the form it does nothing with the uploaded files. I can't find them in the anywhere, not even the localhost tmp directory.

 

I know the flash file is complex, and for the most part it doesn't need to be changed, because I have passed variable to flash via, _GET & _POST before, and it works when the variable is static.

Just a note on request variables.

 

http://us3.php.net/manual/en/reserved.variables.request.php

 

_REQUEST is not deprecated.

 

It is an associative array containing the contents of $_GET, $_POST and $_COOKIE.

 

If, as is the usual case, you know where your request is coming from you're better off sticking to $_GET or $_POST, depending on your request type.

 

Sometimes you may find your system will send data using $_GET or $_POST under different situations, at this point you may find you have to use $_REQUEST. Realistically you sould be able to design your system in a way that one set of data is sent using one request type, and you should then stick to it.

Just a note on request variables.

 

http://us3.php.net/manual/en/reserved.variables.request.php

 

_REQUEST is not deprecated.

 

It is an associative array containing the contents of $_GET, $_POST and $_COOKIE.

 

If, as is the usual case, you know where your request is coming from you're better off sticking to $_GET or $_POST, depending on your request type.

 

Sometimes you may find your system will send data using $_GET or $_POST under different situations, at this point you may find you have to use $_REQUEST. Realistically you sould be able to design your system in a way that one set of data is sent using one request type, and you should then stick to it.

thanks for this...

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.