[PHP] Upload wont work, OS X
I have trouble using upload scripts - none of them work on my current config. I'vq got php 4.2.3 and global registerd = off. The problem is that the script doesnt send the variable $_FILES['my_file'] as it should. I can only upload if i hard code the filename into the script. OS: OS X 10.2 PHP: PHP 4.2.3 MYSQL: 3.23.51 // the script i've tried, it works with older versions av php. ?php // Programmerer: Kim aka astrox // Mail: [EMAIL PROTECTED] // Dato: 19.04.2002 // Hjemmeisde: www.htmlhjelp.no ? h3Bilde upload/h3 Dette scriptet uploader bilder og bare bilder!br Dvs.. *.jpg, *.gif og *.pngbrbr ?php #Config $MAX_FILE_SIZE = $_POST['MAX_FILE_SIZE']; $bilde_fil = $_FILES['bilde_fil']; // HTTP_POST_FILES $nyttnavn = $_POST['nyttnavn']; $ending = $_POST['ending']; $Upload = $_POST['Upload']; echo is_array($HTTP_POST_FILES['bilde_fil']); print_r($bilde_fil); print $bilde_fil; $path=upload; //Mappa som bildene skal havne i (husk den siste '/') #Ikke rediger under her hvis du ikke vet hva du driver med :) if ($bilde_fil $nyttnavn){ $ok = 1; if (is_file($path.$nyttnavn.$ending)){ print bSorry/b, fila eksisterer allerede, finn p et nytt navn.br; $ok = 0; } if (preg_match(/^[\/\\\.]/, $nyttnavn)){ print bSorry/b, filnavnet kan ikke begynne ned: '.', '/' eller '\'br; $ok = 0; } if (!($ending == .jpg || $ending == .gif || $ending == .png)){ print bSorry/b, ingen triksing med filendingen ($ending) takk!br; $ok = 0; } print br; } if ($ok){ $res = copy($bilde_fil, $path./.$nyttnavn.$ending); print ($res)?bFerdig/b, uploadet .$nyttnavn.$ending.!br:bSorry/b, Kunne ikke uploade.br; print br; } ? form name=formen action=upload.php method=post enctype=multipart/form-data input type=hidden name=MAX_FILE_SIZE value=100 Bilde: input type=file name=bilde_filbr Hva skal fila hete p servern: input type=text name=nyttnavn select name=ending option.jpg/option option.png/option option.gif/option /select brbrinput type=submit value=Upload /form
Re: [PHP] Upload wont work, OS X
Hi Magnus, Your problem was you weren't using the correct part of the $_FILES array when using copy(); Cut and Past This: if ($ok){ $res = copy($bilde_fil[tmp_name], $path./.$nyttnavn.$ending); print ($res)?bFerdig/b, uploadet .$nyttnavn.$ending.!br:bSorry/b, Kunne ikke uploade.br; print br; } ? The Important bit is the $bilde_fil[tmp_name] bit. This means it's copying the file from the temporary location on the server to your chosen location. Also, as a side note, replace this too: $MAX_FILE_SIZE = 100; $bilde_fil = $_FILES['bilde_fil']; // HTTP_POST_FILES $nyttnavn = $_POST['nyttnavn']; $ending = $_POST['ending']; if($bilde_fil[size] $MAX_FILE_SIZE) { die(bSorry/b, Kunne ikke uploade.br); } $path=upload; //Mappa som bildene skal havne i (husk den siste '/') Don't set $MAX_FILE_SIZE using $_POST variables for security reasons - someone could very easily alter it in the HTML file!!! Beth Gore magnus nilsson wrote: I have trouble using upload scripts - none of them work on my current config. I'vq got php 4.2.3 and global registerd = off. The problem is that the script doesnt send the variable $_FILES['my_file'] as it should. I can only upload if i hard code the filename into the script. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Upload wont work, OS X
It works, partially. I can upload the file, but it's named array. On fredag, nov 29, 2002, at 16:28 Europe/Stockholm, Beth Gore wrote: Hi Magnus, Your problem was you weren't using the correct part of the $_FILES array when using copy(); Cut and Past This: if ($ok){ $res = copy($bilde_fil[tmp_name], $path./.$nyttnavn.$ending); print ($res)?bFerdig/b, uploadet .$nyttnavn.$ending.!br:bSorry/b, Kunne ikke uploade.br; print br; } ? The Important bit is the $bilde_fil[tmp_name] bit. This means it's copying the file from the temporary location on the server to your chosen location. Also, as a side note, replace this too: $MAX_FILE_SIZE = 100; $bilde_fil = $_FILES['bilde_fil']; // HTTP_POST_FILES $nyttnavn = $_POST['nyttnavn']; $ending = $_POST['ending']; if($bilde_fil[size] $MAX_FILE_SIZE) { die(bSorry/b, Kunne ikke uploade.br); } $path=upload; //Mappa som bildene skal havne i (husk den siste '/') Don't set $MAX_FILE_SIZE using $_POST variables for security reasons - someone could very easily alter it in the HTML file!!! Beth Gore magnus nilsson wrote: I have trouble using upload scripts - none of them work on my current config. I'vq got php 4.2.3 and global registerd = off. The problem is that the script doesnt send the variable $_FILES['my_file'] as it should. I can only upload if i hard code the filename into the script. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Upload wont work, OS X
On Saturday 30 November 2002 06:42, magnus nilsson wrote: It works, partially. I can upload the file, but it's named array. print_r($_FILES) to see what it contains and how you can use it. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* The Beatles: Paul McCartney's old back-up band. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php