Wolphie Posted November 13, 2007 Share Posted November 13, 2007 I'm pretty baffled at this. I'm not entirely sure why this isn't working: $filetype = $_POST['file']['type']; // getting the file type $file = explode('.', $filetype); // exploding the string to return just the file type $filename = rand() . '.' . $file[1]; // renaming it and then adding the file type back to save the file I'm trying to retrieve the file type seperately and then rename it. Link to comment https://forums.phpfreaks.com/topic/77212-explode/ Share on other sites More sharing options...
kenrbnsn Posted November 13, 2007 Share Posted November 13, 2007 What is your question? What are you trying to do? Ken Link to comment https://forums.phpfreaks.com/topic/77212-explode/#findComment-390911 Share on other sites More sharing options...
Wolphie Posted November 13, 2007 Author Share Posted November 13, 2007 *edited* Link to comment https://forums.phpfreaks.com/topic/77212-explode/#findComment-390912 Share on other sites More sharing options...
revraz Posted November 13, 2007 Share Posted November 13, 2007 What is in this array? $_POST['file']['type'] Why not just pull the last three characters of the string? Link to comment https://forums.phpfreaks.com/topic/77212-explode/#findComment-390914 Share on other sites More sharing options...
Wolphie Posted November 13, 2007 Author Share Posted November 13, 2007 That's what i'm trying to do Link to comment https://forums.phpfreaks.com/topic/77212-explode/#findComment-390918 Share on other sites More sharing options...
Wolphie Posted November 13, 2007 Author Share Posted November 13, 2007 Sorry, i just got extremely confused and made a typo. It's meant to be $_FILES['file']['name']; I'm just tired, and been coding all day. Getting too much. -.- Link to comment https://forums.phpfreaks.com/topic/77212-explode/#findComment-390920 Share on other sites More sharing options...
gin Posted November 14, 2007 Share Posted November 14, 2007 What's the error? I can't see anything wrong with that piece of code. Link to comment https://forums.phpfreaks.com/topic/77212-explode/#findComment-391133 Share on other sites More sharing options...
pocobueno1388 Posted November 14, 2007 Share Posted November 14, 2007 Take this for example <?php if (isset($_POST['upload'])){ $name = $_FILES['uploadedfile']['name']; //The name of the file, EX - name.jpg $name = explode('.', $name); $ext = $name[1]; //The type of file/extension, EX - .jpg echo $ext; } ?> <form enctype="multipart/form-data" action="z.php" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="100000" /> Choose a file to upload: <input name="uploadedfile" type="file" /><br /> <input type="submit" value="Upload File" /> </form> You need to use the $_FILES variable to retrieve information about the file. First take a look at this line $name = $_FILES['uploadedfile']['name']; Where it says "uploadedfile", that is where you need to put the name of the input, which in the example, comes from this line Choose a file to upload: <input name="uploadedfile" type="file" /><br /> See if you can work out your problem by looking at that, if not just let us know. Link to comment https://forums.phpfreaks.com/topic/77212-explode/#findComment-391138 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.