rsammy Posted April 10, 2009 Share Posted April 10, 2009 hi, i am trying to upload a file (any file) to a server (in this case, my local machine). i have created two php files (named main.php and upload.php). i launch main.php and it lets me browse for a file. i select a file, say abc.txt and then click on the Upload button. at this point, what it does is, throw up a dialog box asking me if I want to open or save this file (upload.php) with Open, Save and Cancel buttons. When I click Open. it opens upload.php file in notepad/editpad. if i click Save, it lets me choose a folder to save this file for me. however, this is not what i want it to do. i would like it to save the file i chose initially (abc.txt) in a locaion i choose and i should not be worried about my upload.php script file. here is the code in my upload.php file: <?php alert "HERE"; //$web = 'c:/wamp/uploads/'; // path under webroot $web = 'c:/wamp/www/'; // path under webroot $destination =$_FILES['updfile']['name']; if ($_POST['btn'] == "Upload") { if(empty($_POST['userid'])) //Check for User ID { echo "User ID should not be Blank!!<br/>"; } else { $uploaddir = $web."".$_POST['userid']; if(!is_dir($uploaddir)) // Check for existing directory else create new dir for the user { mkdir($uploaddir); } $uploadfile = $uploaddir."/".basename($destination); if(isset($_FILES['updfile']['tmp_name'])) { if(($_FILES['updfile']['error'] == 0) && !empty($_FILES['updfile']) && !file_exists($uploadfile)) { if(move_uploaded_file($_FILES['updfile']['tmp_name'],$uploadfile)) { echo "File Uploaded Successfully!!!<br/>"; } } else echo "File Upload Failed"; } } } ?> <form> <table border ="0"> <tr> <td> List of Filenames : </td> <td> <select name="filenames" id="fields" > <?php if ($dh = opendir($uploaddir)) { while (($file = readdir($dh)) !== false) { $options = NULL; $options.= '<option value="'.$file.'">'.$file.'</option>'."\n"; echo $options; } closedir($dh); } ?> </select> </td> </tr> </form> Link to comment https://forums.phpfreaks.com/topic/153542-file-upload-script-problem/ Share on other sites More sharing options...
schilly Posted April 10, 2009 Share Posted April 10, 2009 i dont see anything in there about open, save or cancel. Link to comment https://forums.phpfreaks.com/topic/153542-file-upload-script-problem/#findComment-806924 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.