karldesign Posted April 9, 2008 Share Posted April 9, 2008 Hi all, I have the following form item: <input id="formImage" name="formImage" type="file" /> I want to store the value of the image to be uploaded in the box if the form was not successfully submitted, similar to: <input id="formName" name="formName" type="text" value="<?= $_POST['formName'];?>" /> Any help would be greatly appreciated. Link to comment https://forums.phpfreaks.com/topic/100381-file-upload-data/ Share on other sites More sharing options...
karldesign Posted April 9, 2008 Author Share Posted April 9, 2008 also, which is the image upload type to be used: copy($_FILES['formImage']['tmp_name'], $img_dir.$nextId.".jpg"); //or move_uploaded_file($_FILES['formImage']['tmp_name'], $img_dir.$nextId.".jpg"); Link to comment https://forums.phpfreaks.com/topic/100381-file-upload-data/#findComment-513337 Share on other sites More sharing options...
matto Posted April 9, 2008 Share Posted April 9, 2008 you are best to use move_uploaded_file() rather than copy() - the reason for this is copy() just copies the file from the upload_tmp_dir rather than moving it to it's new location. Link to comment https://forums.phpfreaks.com/topic/100381-file-upload-data/#findComment-513366 Share on other sites More sharing options...
karldesign Posted April 9, 2008 Author Share Posted April 9, 2008 ok, cool... any ideas about the initial question? Link to comment https://forums.phpfreaks.com/topic/100381-file-upload-data/#findComment-513370 Share on other sites More sharing options...
matto Posted April 9, 2008 Share Posted April 9, 2008 Shouldn't this line <input id="formName" name="formName" type="text" value="<?= $_POST['formName'];?>" /> be <input id="formName" name="formName" type="text" value="<?= $_FILES['formImage']['name'];?>" /> Link to comment https://forums.phpfreaks.com/topic/100381-file-upload-data/#findComment-513391 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.