PDA

View Full Version : uploading a file ....


HormonX
10-24-2002, 02:47 AM
As usuall i need some help :) .. this tim eit's file uploading ... i have a simple script and it works great when i use it on a single page .. i mean that if i use the form and file upload process on the same page it works great ... but i have a form on one page .. and then the form is being submited on the other page and that where the file is being uploaded. Anyhow it should be uploaded.

Am assuming it has something to do with the full path of the file.

here is ther script ...



<?php

$path = "/upd/";
$max_size = 200000;

if (is_uploaded_file($userfile)) {

if ($userfile_size>$max_size) { echo "The file is too big<br>\n"; exit; }

if (($userfile_type=="image/gif") || ($userfile_type=="image/pjpeg")) {

if (file_exists($path . $userfile_name)) { echo "The file already exists<br>\n"; exit; }

$res = copy($userfile, $path . $userfile_name);
if (!$res) {
echo "upload failed!<br>\n"; exit; }
else
echo "upload sucessful<br>\n";

echo "File Name: $userfile_name<br>\n";
echo "File Size: $userfile_size bytes<br>\n";
echo "File Type: $userfile_type<br>\n";
} else { echo "Wrong file type<br>\n"; exit; }

}

?>


and the error i get while trying to upload on the other page .. is


Warning: Unable to create 'master.gif': Permission denied in /home/mydomain/public_html/ver_form.php on line 152
upload failed!


The directory is there .. i even gave the folder full permition just to see .. and it's still the same thing.

Please help ...

HormonX

Ökii
10-24-2002, 04:56 PM
try

move_uploaded_file($userfile,$path.$userfile_name);

also note: $path will be relative to the topmost document in the parse chain, so if you are including your script in an outer document then path would relate to that.

HormonX
10-24-2002, 06:22 PM
I tried and nothing ... i belive it has something to do with permitions.

am still getting error message


Warning: Unable to create 'granat.jpg': Permission denied in /home/mydomain/public_html/do1.php on line 399

Warning: Unable to move '/tmp/phpRpahUq' to 'granat.jpg' in /home/mydomain/public_html/do1.php on line 399
upload failed!


thanx for your help ..

HormonX
10-24-2002, 06:55 PM
is there something in the path am missing ? because it seems that way ... please help !! :)

when i have the form and i upload to the same folder as the file it works .. but when i have the file outside the folder and i want to upload the file there ... t's just doesn't work ...

please help ... am going insane !! :)

HormonX

Ökii
10-24-2002, 08:00 PM
of course (++ d'oh)

any path started with \ tells the server to start at root - from your root you do not have a upd folder (just [home] [tmp] and probby [cgi-bin] or whatnot).

Simple fix....

$path = "upd/";

:D