Lisa23 Posted September 27, 2010 Share Posted September 27, 2010 Hi i have a simple triple upload file script that upload files with its own name it works fine but what i want is to be able to specify the name of the image like file 1 give name (blue) file 2 name (tree) file 3 name (sky) <?php //set where you want to store files //in this example we keep file in folder upload //$HTTP_POST_FILES['ufile']['name']; = upload file name //for example upload file name cartoon.gif . $path will be upload/cartoon.gif $path1= "images/posters/".$_FILES['ufile']['name'][0]; $path2= "images/posters/".$_FILES['ufile']['name'][1]; $path3= "images/posters/".$_FILES['ufile']['name'][2]; //copy file to where you want to store file copy($_FILES['ufile']['tmp_name'][0], $path1); copy($_FILES['ufile']['tmp_name'][1], $path2); copy($_FILES['ufile']['tmp_name'][2], $path3); //$HTTP_POST_FILES['ufile']['name'] = file name //$HTTP_POST_FILES['ufile']['size'] = file size //$HTTP_POST_FILES['ufile']['type'] = type of file echo "File Name :".$_FILES['ufile']['name'][0]."<BR/>"; echo "File Size :".$_FILES['ufile']['size'][0]."<BR/>"; echo "File Type :".$_FILES['ufile']['type'][0]."<BR/>"; echo "<img src=\"$path1\" width=\"150\" height=\"150\">"; echo "<P>"; echo "File Name :".$_FILES['ufile']['name'][1]."<BR/>"; echo "File Size :".$_FILES['ufile']['size'][1]."<BR/>"; echo "File Type :".$_FILES['ufile']['type'][1]."<BR/>"; echo "<img src=\"$path2\" width=\"150\" height=\"150\">"; echo "<P>"; echo "File Name :".$_FILES['ufile']['name'][2]."<BR/>"; echo "File Size :".$_FILES['ufile']['size'][2]."<BR/>"; echo "File Type :".$_FILES['ufile']['type'][2]."<BR/>"; echo "<img src=\"$path3\" width=\"150\" height=\"150\">"; /////////////////////////////////////////////////////// // Use this code to display the error or success. $filesize1=$_FILES['ufile']['size'][0]; $filesize2=$_FILES['ufile']['size'][1]; $filesize3=$_FILES['ufile']['size'][2]; if($filesize1 && $filesize2 && $filesize3 != 0) { echo "We have recieved your files"; } else { echo "ERROR....."; } ////////////////////////////////////////////// // What files that have a problem? (if found) if($filesize1==0) { echo "There're something error in your first file"; echo "<BR />"; } if($filesize2==0) { echo "There're something error in your second file"; echo "<BR />"; } if($filesize3==0) { echo "There're something error in your third file"; echo "<BR />"; } ?> Link to comment https://forums.phpfreaks.com/topic/214495-rename-simple-upload-file/ Share on other sites More sharing options...
jcbones Posted September 27, 2010 Share Posted September 27, 2010 I would use move_uploaded_file(). But the answer to your question is: $path1= "images/posters/blue.jpg"; $path2= "images/posters/tree.jpg"; $path3= "images/posters/sky.jpg"; Link to comment https://forums.phpfreaks.com/topic/214495-rename-simple-upload-file/#findComment-1116140 Share on other sites More sharing options...
Lisa23 Posted September 27, 2010 Author Share Posted September 27, 2010 I would use move_uploaded_file(). But the answer to your question is: $path1= "images/posters/blue.jpg"; $path2= "images/posters/tree.jpg"; $path3= "images/posters/sky.jpg"; do u mean replace this $path1= "images/posters/".$_FILES['ufile']['name'][0]; $path2= "images/posters/".$_FILES['ufile']['name'][1]; $path3= "images/posters/".$_FILES['ufile']['name'][2]; with what u sent me or put that next to it?? Link to comment https://forums.phpfreaks.com/topic/214495-rename-simple-upload-file/#findComment-1116142 Share on other sites More sharing options...
Lisa23 Posted September 27, 2010 Author Share Posted September 27, 2010 thanks put next to it one last question how can i resize??? Link to comment https://forums.phpfreaks.com/topic/214495-rename-simple-upload-file/#findComment-1116144 Share on other sites More sharing options...
jcbones Posted September 27, 2010 Share Posted September 27, 2010 For simplicities sake, I think you should use the simpleImage class. if( isset($_POST['submit']) ) { include('SimpleImage.php'); $image = new SimpleImage(); $image->load($_FILES['uploaded_image']['tmp_name']); $image->resize(150,150); $image->save($filename); } Link to comment https://forums.phpfreaks.com/topic/214495-rename-simple-upload-file/#findComment-1116165 Share on other sites More sharing options...
chintansshah Posted September 27, 2010 Share Posted September 27, 2010 for resize image read below link http://php.net/manual/en/function.imagecopyresampled.php Link to comment https://forums.phpfreaks.com/topic/214495-rename-simple-upload-file/#findComment-1116185 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.