Page 1 of 1

Problems with uploading! Help please!

Posted: Mon Mar 01, 2004 3:25 am
by sandrol76
Hello to everybody,
I have a problem with uploading a file. Using the following code:
if(is_uploaded_file($_FILES["foto"]["tmp_name"]))
{
//check type and syze
if ($_FILES["foto"]["name"] != "") {
$imageType = $_FILES["foto"]["type"];

// Check MIME Type
$inpiccolo = strtolower($imageType);
if (($inpiccolo != "image/png") && ($inpiccolo != "image/pjpeg") && ($inpiccolo != "image/jpeg") && ($inpiccolo != "image/gif"))
die("<center><h1>Puoi selezionare solo file di immagini</h1></center>");
}

if($_FILES["foto"]["size"] > 62000)
die("<center><h1>Puoi selezionare solo foto di dimensione max. 60 KB</h1><center>");

//set the URL for the upload
$path = "images/offerte/".$_FILES["foto"][" name"];

//upload the file
move_uploaded_file($_FILES["foto"]["tmp_name"], $path);
}

I try to upload an image as you can see from the code! the problem is the it works fine in local but it doesn't when I use it in the server!
I also tried to use $HTTP_POST_FILES instead of $_FILES but it doesn't work either! You can check the php configuration of the server at http://www.k2club4wd.com/nuovomare/phpinfo.php so you can tell me if there is some problem that i don't know as i'm new at php! thank you very much anyway! I was forgetting...move_uploaded_file(...) return false without any warning if this may help!

Posted: Mon Mar 01, 2004 9:22 am
by AVATAr
do you have write permissions on the directory you want to use?

Posted: Mon Mar 01, 2004 9:37 am
by Steveo31
Hmm, how would one go about that?

Posted: Mon Mar 01, 2004 9:39 am
by AVATAr
is there any error message? put in the top error_reporting(E_ALL)

Posted: Mon Mar 01, 2004 10:46 am
by andre_c
From what I understand, he doesn't need to set permissions since it's a windows server, is that right?

Posted: Mon Mar 01, 2004 2:00 pm
by sandrol76
putting error_reporting(E_ALL) i got this warning:
Warning: move_uploaded_file(images/offerte/parafly3.jpg): failed to open stream: Permission denied in D:\Inetpub\webs\k2club4wdcom\nuovomare\store.php on line 30

Warning: move_uploaded_file(): Unable to move 'C:\PHP\uploadtemp\phpF996.tmp' to 'images/offerte/parafly3.jpg' in D:\Inetpub\webs\k2club4wdcom\nuovomare\store.php on line 30

and I found out i didn't have the permission to write to that folder...even if i created that folder! anyway i worked it out, thank you very much!
I have another question though...what's more performing, uploading the file using ftp_put or using move_uploaded_file?