Jump to content

Basic File Upload without ftp access


swatisonee

Recommended Posts

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 !
Swati

File1
===


[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]
Link to comment
https://forums.phpfreaks.com/topic/8523-basic-file-upload-without-ftp-access/
Share on other sites

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.