Click to See Complete Forum and Search --> : file upload?
DARTHTAMPON
10-03-2004, 06:23 PM
looking for some good file uplaod how-to's. have searched the internet and have found very little. does anybody have any good links for this or how-tos they can post?
Not looking for a script, looking to learn how to write a script.
thx
MstrBob
10-03-2004, 06:26 PM
Did you try the PHP manual (PHP.net)?
http://us4.php.net/features.file-upload
DARTHTAMPON
10-03-2004, 06:36 PM
for the html side MAX_FILE_SIZE, if I have more than 1 file to uplad can i put different sizes for each. Will this give me an error or use the same file size for all of the files.
MstrBob
10-03-2004, 06:44 PM
MAX_FILE_SIZE is more important to the browser. If you have multiple upload inputs, than I'd say that your best bet is to have MAX_FILE_SIZE equal the max file size of the largest file. If you want the other uploads to have smaller max file size, tell the user the max file size for those uploads, and then check the individual files in your PHP. But only have one max file size input tag.
DARTHTAMPON
10-07-2004, 10:55 PM
Changing upload_tmp_dir in php.ini allows you to change the directory where files go when uploaded.
Is there a way to change it in a program, so if i have 5 different upload utilites each can have their own file upload directory?
Paul Jr
10-08-2004, 03:35 PM
The upload_tmp_dir directive is just the temporary upload directory; after the file is uploaded to that temporary directory, you copy it over to your desired directory.
DARTHTAMPON
10-08-2004, 07:32 PM
Can I use actual command line code?
mv -f location1/filename location2/differentfilename
and is this command correct, can I change a filename on a move.
Paul Jr
10-09-2004, 12:08 AM
Originally posted by DARTHTAMPON
Can I use actual command line code?
mv -f location1/filename location2/differentfilename
and is this command correct, can I change a filename on a move.
I couldn’t say; I’ve never used PHP through the command line. Sorry.
drythirst
10-09-2004, 09:27 AM
What's PHP through the command line code?? Whoa, sounds old...
Or are you talking about the PHP command line codes???
:confused: :confused: :confused: :confused: :confused: :confused:
MstrBob
10-09-2004, 10:24 AM
Why not simply use the move_uploaded_file() (http://us2.php.net/manual/en/function.move-uploaded-file.php) function? You can rename a file easily enough, as well
DARTHTAMPON
10-09-2004, 10:20 PM
ok so I have this code====
$uploadfiles = array("logosmall", "logomedium", "logolarge", "about");
$filenameextension = array("s_", "m_", "l_", "a_");
$files = array();
getfileinfo($files, $uploadfiles, $filenameextension);
function getfileinfo (&$files, $uploadfiles, $filenameextension)
{
for ($x = 0; $x < sizeof($uploadfiles); $x++)
{
if( !(strlen($_FILES[$uploadfiles[$x]]['name']) < 1 ))
{
$files[$x][0] = $_FILES[$uploadfiles[$x]]['name']; # name of file
$files[$x][1] = $_FILES[$uploadfiles[$x]]['type']; # file type jpg gif etc
$files[$x][2] = $_FILES[$uploadfiles[$x]]['size']; # size of file
$files[$x][3] = $_FILES[$uploadfiles[$x]]['tmp_name']; # temp name of file on server
$files[$x][4] = $_FILES[$uploadfiles[$x]]['error']; # errors
# move file from temp directory to the temp directory of this file
if (move_uploaded_file($_FILES[$uploadfiles[$x]]['name'], $_SERVER['PHP_SELF']."/temp/".$filenameextension[$x].$files[$x][0]))
{
echo "yes";
}
else
{
echo "no";
}
echo $_SERVER['PHP_SELF']."/temp/".$filenameextension[$x].$files[$x][0]."<br>";
}
}
now all of the information comes out correct the output on the page becomes /caboo/db_input/brands/brand2.php/temp/s_test.txt when i try to upload a text file called test. everything seems to look fine but no file is ever uploaded. The temp directory i created i chmod 777. does anybody see anything that might be wrong or can anybody give me a clue