web_master Posted April 21, 2008 Share Posted April 21, 2008 Hi, I use this simple script to upload files on server: <?php if ($_FILES["file"]["name"]) { $destination = "images/".$request['file_id']."_file.pdf"; move_uploaded_file($_FILES["file"]["tmp_name"], $destination); } ?> This mean example: 25_file.pdf So, I want to use a same relations mean add ID but the extesion of file let be what is the original... If I upload an file with extension xls that will looks like 25_file.xls with pdf 25_file.pdf ... how recognise the PHP the extension and how can I do it with script? thanx Link to comment https://forums.phpfreaks.com/topic/102159-upload-different-file-extensions-with-one-form/ Share on other sites More sharing options...
cooldude832 Posted April 21, 2008 Share Posted April 21, 2008 $_FILES is a superglobal array that stores all data of the files uploaded in the last upload session. So you would need to use additional form inputs to allow additional file uploads Note your uploader is very crude and dangerous Link to comment https://forums.phpfreaks.com/topic/102159-upload-different-file-extensions-with-one-form/#findComment-522908 Share on other sites More sharing options...
web_master Posted April 21, 2008 Author Share Posted April 21, 2008 $_FILES is a superglobal array that stores all data of the files uploaded in the last upload session. So you would need to use additional form inputs to allow additional file uploads Note your uploader is very crude and dangerous well, this is the form what will send the file <form action="<?php print $_SERVER['PHP_SELF'];?>" method="post" enctype="multipart/form-data"> <input type="file" name="file" size="35" /> <input type="submit" name="file_submit" value="SEND" /> <input type="hidden" name="file_id" value="<?php print $request['file_id'];?>" /> </form> This is simple script, because this is the only way to understand how its work... If I miss something secure stuff - please tell me that thnxs Link to comment https://forums.phpfreaks.com/topic/102159-upload-different-file-extensions-with-one-form/#findComment-522914 Share on other sites More sharing options...
web_master Posted April 21, 2008 Author Share Posted April 21, 2008 plus... <input type="hidden" name="MAX_FILE_SIZE" value="100000" /> Link to comment https://forums.phpfreaks.com/topic/102159-upload-different-file-extensions-with-one-form/#findComment-522924 Share on other sites More sharing options...
cooldude832 Posted April 21, 2008 Share Posted April 21, 2008 the MAX_FILE_SIZE is a oldschool way to restrict size its not really super important your input type needs to have a better than than "file" use "xls_upload" or "pdf_upload" don't know why you have a file_id in the form. your form should be <form action="<?php echo $_SERVER['PHP_SELF'];?>"> method="post" enctype="multipart/form-data"> <input type="file" name="xls_file" /> <input type="file" name="pdf_file"/> <input type="submit" value="submit" /> </form> <?php print_r($_FILES); ?> Link to comment https://forums.phpfreaks.com/topic/102159-upload-different-file-extensions-with-one-form/#findComment-522931 Share on other sites More sharing options...
web_master Posted April 21, 2008 Author Share Posted April 21, 2008 cooldude832, sorry, I forgot why is import, mean file_id, because when I upload file there will be the explanation for a file. If I upload the file, there will the visitor see this: This is excell table for something | file size 100k | [and some icon] When he click on "This is excell table for something" text this will download for him a 25_file.xls file. so that why I need file_id - text will go in dBase. I want to upload the files with only one "<input type="file" name="file" size="35" />"... if is possible, because I dont know what type (extension) of file will be uploaded. <form action="<?php print $_SERVER['PHP_SELF'];?>" method="post" enctype="multipart/form-data"> <input type="text" name="file_explain" /> <input type="file" name="file" size="35" /> <input type="submit" name="file_submit" value="SEND" /> <input type="hidden" name="file_id" value="<?php print $request['file_id'];?>" /> </form> Link to comment https://forums.phpfreaks.com/topic/102159-upload-different-file-extensions-with-one-form/#findComment-522947 Share on other sites More sharing options...
cooldude832 Posted April 21, 2008 Share Posted April 21, 2008 read up on this cause I'm not going to repost a whole basic file upload tutorial here. Also you have no clue how the file input type works because the size parameter isn't going to do anything for you that is useful for the php portion. Link to comment https://forums.phpfreaks.com/topic/102159-upload-different-file-extensions-with-one-form/#findComment-522949 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.