Forum Moderators: coopster

Message Too Old, No Replies

upload file with php

         

Phobia1

10:19 am on Nov 22, 2008 (gmt 0)

10+ Year Member



Hi Guys, I am sure that this topic is already worn out but if you can find the time to help me out once again.
I am trying to create a page to upload files to our website. Always will be only jpg or gif format.
This is as far as I have got. Can't get it to work and may be problems with my system as no temp-folder is shown.
Thaks in advance
FJw

upload.php
</head>
<body>
<form action="" method="post" enctype="multipart/form-data" name="frm_upload" id="frm_upload">
<table border="0" cellspacing="0" cellpadding="0" id="tbl_upload">
<tr>
<th scope="row"><label for="frmname">Full name:</label></th>
<td><input type="text" name="frmname" id="frmname" class="frmfld" /></td>
</tr>
<tr>
<th scope="row"><label for="frmfile">File:</label></th>
<td><input name="frmfile" type="file" id="frmfile" size="30" /></td>
</tr>
<tr>
<th scope="row"> </th>
<td>
<label for="btn" id="sbm">
<input type="submit" name="btn" id="btn" value="Upload" />
</label>
</td>
</tr>
</table>
</form>
<pre>

<?php
if (array_key_exists('btn', $_POST)) {
print_r($_FILES);

// define new constant which contains the path to the upload folder
define('UPL_FLD','uploads/');

// move file to the 'uploads' folder
move_uploaded_file($_FILES['frmfile']['tmp_name'],UPL_FLD.$_FILES['frmfile']['name']);
}
?>
</pre>

</body>

</html>

my result - with error 6 no temporary file
Array
(
[frmfile] => Array
(
[name] => 812sm.jpg
[type] =>
[tmp_name] =>
[error] => 6
[size] => 0
)

)

vincevincevince

10:34 am on Nov 22, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Value: 6; Missing a temporary folder. Introduced in PHP 4.3.10 and PHP 5.0.3.

Check your php.ini configuration to ensure that you have set a temporary folder which is writeable by the web-server process.

Phobia1

11:07 am on Nov 22, 2008 (gmt 0)

10+ Year Member



Hi, yes, I have already tried that, and set even to c:uploads but still have error 6

vincevincevince

11:57 am on Nov 22, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



c:uploads is not correct; try "c:/uploads/"

View your error logs to verify what's going on here!

I feel a touch of sadness when I hear someone's running PHP on windows. :-(

Phobia1

1:39 pm on Nov 22, 2008 (gmt 0)

10+ Year Member



sorry I meant that I made c:/uploads/ I will check the logs.

Scooter

2:08 pm on Nov 26, 2008 (gmt 0)

10+ Year Member



try going with the system directories your server goes by. I`m almost certain that you need to do this. Its the server directory structure that might show up at your ftp program.

e.g.
define("UPL_FLD", "/var/www/html/uploads");
define("UPL_FLD", "/public_html/uploads");

also by default your system might have a 2M php upload limit, which you can override easily, fyi.

Phobia1

2:31 pm on Nov 26, 2008 (gmt 0)

10+ Year Member



Thanks for all of your replies, I appreciate much all of them. SinceI couldn't make my uploads work, I took cover point uploader from the web (Todd Strattman). Super and has solved all of my upload problems without further headaches. Nest regards from Bulgaria. FJW