swatisonee Posted April 27, 2006 Share Posted April 27, 2006 Hi,I need to give 5 users only, a way of uploading reports onto our server , which can then be downloaded by us. These will be either word/excel/jpeg files only. Currently, they email it to us but we need the files to be accessible on the server itself. Following is the snippet of scripts i use for email. How can i modify so that instead of being in a temp file, it remains permanently there. I dont want to give these users ftp access to the server.Thanks !SwatiFile1===[code]<table> <tr><td>Upload a file:</td><td><input name="userfile" type="file">File size should not exceed 2MB</td></tr><p><p></table> <p> <br><input type="submit" name="submit" value="Submit"> </p> </form>[/code]File2===[code]Start of emailing code by posting other info...if(!($_FILES["userfile"]["name"]=="")) { $uploaddir="./send_email/"; //copy the file to some permanent location which has 777 permissions if (move_uploaded_file($_FILES["userfile"]["tmp_name"], $uploaddir.$_FILES["userfile"]["name"])) { echo("<p>File uploaded<p><p>"); } else { echo ("<p>Error in uploading file! Please try again.<br>"); if($_FILES['userfile']['error']==1) echo "<font color=red>Error: File size exceeds maximum permissible limit of 2MB</font><p><p>"; }} Rest of emailing code...File attached: ".$_FILES["userfile"]["name"];if(!$mail->Send()){ echo "Message could not be sent. <p>"; echo "Mailer Error: " . $mail->ErrorInfo; exit;}echo "Emailssent successfully.";@unlink($attach);?> [/code] Quote Link to comment https://forums.phpfreaks.com/topic/8523-basic-file-upload-without-ftp-access/ Share on other sites More sharing options...
Twentyoneth Posted April 27, 2006 Share Posted April 27, 2006 Simply rename it?rename("$_FILES["userfile"]["tmp_name"], "permanent location"); Quote Link to comment https://forums.phpfreaks.com/topic/8523-basic-file-upload-without-ftp-access/#findComment-31205 Share on other sites More sharing options...
sanfly Posted April 27, 2006 Share Posted April 27, 2006 Is there somewhere in the bit of code you have left out where you define $attach as the upload_dir/file_name?If so, remove the line that deletes the file from the server[code]@unlink($attach);[/code] Quote Link to comment https://forums.phpfreaks.com/topic/8523-basic-file-upload-without-ftp-access/#findComment-31206 Share on other sites More sharing options...
swatisonee Posted April 28, 2006 Author Share Posted April 28, 2006 Hi Sanfly,The unlink bit is in the code for the php mailer - thats why i didnt copy it. I removed it as you suggested but its not working .a. When we access the folder on the server, how do we know which files the user has uploaded and their names? Example: Files on server : a.doc, b.xls, c.jpg. But i cannot view this list or click on it to download.....b. Since the file is called tmp_name its creating a problem if 2 users simultaneously try to upload....Thanks.Swati Quote Link to comment https://forums.phpfreaks.com/topic/8523-basic-file-upload-without-ftp-access/#findComment-31521 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.