Fallen_angel Posted November 8, 2006 Share Posted November 8, 2006 I am having a little trouble with my upload script , it will work fine provided the script is in the same folder as the uploads folder , however as soon as I move it into the admin section of my site which is where i want it it stops working , I have tried to play with the $destfile variable in the script bellow but what apears to be correct to me simply isn't workign so If somoen coudl have a look and tell me where i am goign wrong i would really apreciate it [code]<?php//// did the upload succeed or fail?//if ($_FILES['avatarfile']['error'] == UPLOAD_ERR_OK){ // // verify (casually) that this appears to be an image file // $ext = strtolower(pathinfo($_FILES['avatarfile']['name'], PATHINFO_EXTENSION)); switch ($ext) { case 'jpg': case 'jpeg': case 'gif': case 'png': case 'bmp': break; // file type is okay! default: throw new InvalidFileTypeException($ext); } // // move the file to the appropriate location // $destfile = '../foldername/uploads/' . basename($_FILES['avatarfile']['name'] ); $ret = @move_uploaded_file($_FILES['avatarfile']['tmp_name'], $destfile); if ($ret === FALSE) echo "Unable to move user photo!<br/>\n"; else echo "Moved image to uploads directory<br/>\n";}else{ // // see what the error was. // switch ($_FILES['avatarfile']['error']) { case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_FORM_SIZE: throw new FileSizeException(); break; case UPLOAD_ERR_PARTIAL: throw new IncompleteUploadException(); break; case UPLOAD_ERR_NO_FILE: throw new NoFileReceivedException(); break; default: echo "say what?"; break; }}?>[/code]I know the script itself works fine as I can use it if they are within the same directory so I am pretty sure i have to be doign somethign wrong on the $destfile line thanx in advance to anyone that can help out Link to comment https://forums.phpfreaks.com/topic/26528-upload-script/ Share on other sites More sharing options...
Fallen_angel Posted November 8, 2006 Author Share Posted November 8, 2006 How silly of me I should have explained the dir structure aswell home webappfolder uploads < ~~~~ files need to go here .Admin <~~~~~ script is run in here Link to comment https://forums.phpfreaks.com/topic/26528-upload-script/#findComment-121380 Share on other sites More sharing options...
Fallen_angel Posted November 8, 2006 Author Share Posted November 8, 2006 Still having a bit of trouble with this , have played a little more with it now , but still it just won't work and i can't understand why thanx again to anyone that can help Link to comment https://forums.phpfreaks.com/topic/26528-upload-script/#findComment-121863 Share on other sites More sharing options...
mschrank99 Posted November 9, 2006 Share Posted November 9, 2006 You need to post the error otherwise people will not know what to look for in your script. Link to comment https://forums.phpfreaks.com/topic/26528-upload-script/#findComment-121954 Share on other sites More sharing options...
JasonLewis Posted November 9, 2006 Share Posted November 9, 2006 dunno. try using copy(). i prefer to use copy(). also in there is $destfile supposed to be:[code=php:0]$destfile = '../uploads/'.$_FILES['avatarfile']['name'];[/code]thats if the script is located in the Admin folder. Link to comment https://forums.phpfreaks.com/topic/26528-upload-script/#findComment-122011 Share on other sites More sharing options...
Fallen_angel Posted November 10, 2006 Author Share Posted November 10, 2006 $destfile = '../uploads/'.$_FILES['avatarfile']['name'];thats if the script is located in the Admin folder.worked thanx allot !! I coudl have sworn I tried that and it failed before but live and learn i guess thankyou again Link to comment https://forums.phpfreaks.com/topic/26528-upload-script/#findComment-122432 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.